cancel
Showing results for 
Search instead for 
Did you mean: 

Data on a specific cell

Former Member
0 Kudos

hi all,

I tried to fill a row with data that is selected from a cfl how far you've come to is this ...

if (pVal.ItemUID == "colItemCod" || sCflId.ToString() == "CFL_5")
                        {
                            
                            try
                            {
                                SAPbouiCOM.Matrix oMatrix;
                                int i = pVal.Row;

                                oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;

                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", 0, System.Convert.ToString(oDataTable.GetValue("ItemCode", 0)));
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", 0, System.Convert.ToString(oDataTable.GetValue("ItemName", 0)));
                                if(i == oMatrix.RowCount)
                                {
                                     oMatrix.AddRow(1, 0);
                                }
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                            }
                        }

what happens is that when I select a specific cell value does not change...

I have another way to do it but I get an error of type "Item can not get focus"

if (pVal.ItemUID == "colItemCod" || sCflId.ToString() == "CFL_5")
                        {

                            try
                            {
                                SAPbouiCOM.Matrix oMatrix;
                                SAPbouiCOM.EditText oEdit;
                                int i = pVal.Row;

                                oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;

                                
                                oEdit = (SAPbouiCOM.EditText)oMatrix.GetCellSpecific("colItemCod", i);

                                oEdit.String = System.Convert.ToString(oDataTable.GetValue("ItemCode", 0));
                             
                                if(i == oMatrix.RowCount)
                                {
                                    oMatrix.AddRow(1, 0);
                                }
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                            }
                        }
                    }

regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi all,

The behavior remains the same, this is the code I use to add rows to the matrix, I need to do is modify the existing values ​​already present in the matrix.

if (pVal.ItemUID == "colItemCod" || sCflId.ToString() == "CFL_5")
                        {
                            try
                            {
                                SAPbouiCOM.Matrix oMatrix;
                                int i = pVal.Row;

                                oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;

                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").Clear();
                                oMatrix.FlushToDataSource();
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", pVal.Row - 1, oDataTable.GetValue("ItemCode", 0).ToString());
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", pVal.Row - 1, oDataTable.GetValue("ItemName", 0).ToString());
                                

                                if (i == oMatrix.RowCount)
                                {
                                    oMatrix.AddRow(1, 0);
                                }
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                            }  
                        }

The process is done, I mean that values ​​are assigned to the datasource but not show changes.

this is the way I do the matrix...

public void setMatrix()
        {
            SAPbouiCOM.Matrix oMatrix;

            oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;
            oMatrix.AddRow(1, 0);
        }

Regards

former_member689126
Active Contributor
0 Kudos

Hi Jonathan Cuesto

After setting the values to dbdatasource you have to call oMatrix.LoadFromDataSource(); otherwise it will not reflect in your matrix.

Regards

Arun

Former Member
0 Kudos

Hi all,

I'll show you more explicitly what happens to me in this video,

[http://screencastle.com/watch/75c489d1ab392697952e5ff099b73d73]

Regards

former_member689126
Active Contributor
0 Kudos

Hi

just comment the following and try once more

if (i == oMatrix.RowCount)

{

oMatrix.AddRow(1, 0);

}

Regards

Arun

Former Member
0 Kudos

Hi Arun,

it does the work but I can't add by the way, is there another solution?... can we meet on teamviewer to solve this?

My ID is '623 919 642' and my pswd is 7905.

Regards

Edited by: Jonathan Cuesto on Apr 26, 2011 8:57 PM

Edited by: Jonathan Cuesto on Apr 26, 2011 9:02 PM

former_member689126
Active Contributor
0 Kudos

Hi

Yesterday i have some problem with my broadband connection thats why i am not able to connect through team viewer

if (pVal.ItemUID == "colItemCod" || sCflId.ToString() == "CFL_5")
                        {
                            try
                            {
                                SAPbouiCOM.Matrix oMatrix;
                                int i = pVal.Row;
 
                                oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;
 
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").Clear();
                                oMatrix.FlushToDataSource();
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", pVal.Row - 1, oDataTable.GetValue("ItemCode", 0).ToString());
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", pVal.Row - 1, oDataTable.GetValue("ItemName", 0).ToString());
                                
 
                                if (i == oMatrix.RowCount)
                                {
                                 forma.DataSources.DBDataSources.Item("@ZTV_LINES").InsertRecord(i);
                                 forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", i, "");
                                forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", i, ""));


                                }

                                 oMatrix.LoadFromDataSource();
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message);
                            }  
                        }

Hope this help you

Regards

Arun

Former Member
0 Kudos

It really did the work, many thanks for your dedication aruntb...

Answers (2)

Answers (2)

former_member192187
Participant
0 Kudos

if ((pVal.ItemUID == "matrixid") && (pVal.ColUID == "columnid"))

{

oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("mtx_0").Specific;

SAPbouiCOM.DBDataSource db0 = (SAPbouiCOM.DBDataSource)(oForm.DataSources.DBDataSources.Item("@YOURPOSITIONTABLE"));

val = oDataTable.GetValue("ItemCode", 0).ToString();

desc = oDataTable.GetValue("ItemName", 0).ToString();

db0.SetValue("U_dbfield1", pVal.Row - 1, val);

db0.SetValue("U_dbfield2", pVal.Row - 1, desc);

oMatrix.LoadFromDataSource();

oMatrix.AutoResizeColumns();

if (oForm.Mode == SAPbouiCOM.BoFormMode.fm_OK_MODE)

{

oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE;

}

former_member689126
Active Contributor
0 Kudos

Hi

Try this

ItemUID == "colItemCod" || sCflId.ToString() == "CFL_5")

{

try

{

SAPbouiCOM.Matrix oMatrix;

int i = pVal.Row;

oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific;

forma.DataSources.DBDataSources.Item("@ZTV_LINES").Clear();

oMatrix..FlushToDataSource()

forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", 0, System.Convert.ToString(oDataTable.GetValue("ItemCode", 0)));

forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", 0, System.Convert.ToString(oDataTable.GetValue("ItemName", 0)));

oMatrix.LoadFromDataSource()

if(i == oMatrix.RowCount)

{

oMatrix.AddRow(1, 0);

}

}

catch (Exception e)

{

MessageBox.Show(e.Message);

}

}

Hope this helps you

Regards

Arun