Adding a new row into a grid
Emanuele Croci
Dear all,I create a grid in a form.
How can I add a new row to the grid?
What command line should I add?
This is my code:
SwissAddonFramework.UI.Components.Form newForm = SwissAddonFramework.UI.Components.Form.CreateNewForm("TCForm", "TCForm" + SwissAddonFramework.Utils.UniqueStringGenerator.Next());
SwissAddonFramework.UI.Components.Grid myGrid =
SwissAddonFramework.UI.Components.Grid.CreateNew("TC_Grid");
myGrid.FromPane = 77;
myGrid.ToPane = 77;
myGrid.Left = 50;
myGrid.Top = 50;
myGrid.Width = 300;
myGrid.Height = 300;
newForm.AddItem(myGrid);
newForm.PaneLevel = 77;
newForm.Visible = true;
newForm.Load();
string query = @"SELECT T0.U_field1 as 'field1', T0.U_field2 as 'field2', T0.U_field2 as 'field3' FROM [dbo].[@TCPROVACUSTOM] T0 ";
myGrid.ExecuteQuery(query);
myGrid.AffectsFormMode = false;
myGrid.Columns["field2"].Type = GridColumn.Types.ComboBox;
((ComboBoxGridColumn)myGrid.Columns["field2"].SpecificGridColumn).ValidValues.Add("C", "C - Value");
((ComboBoxGridColumn)myGrid.Columns["field2"].SpecificGridColumn).ValidValues.Add("S", "S - Value");
((ComboBoxGridColumn)myGrid.Columns["field2"].SpecificGridColumn).ValidValues.Add("L", "L - Value");
myGrid.Columns["field3"].Editable = true;
ChooseFromList.DefaultSQLQuery queryDef = new ChooseFromList.DefaultSQLQuery("SELECT CardCode, CardName FROM OCRD");
ChooseFromList cfl = new ChooseFromList(queryDef, "CardName", true, false, myGrid, "field3");
cfl.ChooseFromListEvent += new ChooseFromList.ChooseFromListHandler(cfl_ChooseFromListEvent);
newForm.Update();
...
Can someone help me, please?
Regards
Emanuele
Manuel Marhold
Hi Emanuele,take a look at the functions of myGrid.
there must be an AddRow() row Rows.Add().
And please, take a look at the samples and helpfile.
Emanuele Croci
Dear Manuel,I'm sorry, but I read all the "coresuiteFramework_Samples", the "coresuiteFrameworkAPIDocumentation.chm" and customize samples, but I didn't find any example on adding a row in a grid.
The Grid.AddRow() method doesn't exist.
I don't know what class and method should I use to add a new row in a Grid.
I hope you can help me.
Regards
Emanuele
Michael Egloff
Hello Emanuele,because the grid is bound to a DataTable, you can add new rows there.
myGrid.DataTable.Rows.Add();
hth,
Michael
Emanuele Croci
Thank you Michael !!!Emanuele
0
Please sign in to leave a comment.
Comments
0 comments