Detect the row of a grid
Mario Byttebier
Hello,i have created a grid, based on a query.
I would like to know on which row/column my cursor is positioned?
Can somebody give me a solution ?
thx,
Mario
Martin Ehrensberger
Hi Mario,What kind of grid are you using?
Regards,
Martin
Mario Byttebier
Hi Martin,i have created a new form/grid via the new menu functionality and i used
the following code :
SwissAddonFramework.UI.Components.Form newForm = SwissAddonFramework.UI.Components.Form.CreateNewForm("ICD_OQUTF1", "ICD_OQUTF1" + SwissAddonFramework.Utils.UniqueStringGenerator.Next());
SwissAddonFramework.UI.Components.Grid grid = SwissAddonFramework.UI.Components.Grid.CreateNew("ICD_OQUTG1");
grid.FromPane = 77;
grid.ToPane = 77;
grid.Left = 20;
grid.Top = 40;
grid.Width = 1100;
grid.Height = 520;
newForm.AddItem(grid);
Button b1 = Button.CreateNew();
b1.UniqueID = "1";
b1.Top = 565;
b1.Left = 20;
b1.Value = "OK";
newForm.AddItem(b1);
Button b2 = Button.CreateNew();
b2.UniqueID = "3";
b2.Top = 565;
b2.Left = 95;
b2.Width = 165;
b2.Value = "ZOEKEN op BASIS-machines ...";
b2.FontStyle = SwissAddonFramework.UI.Components.Item.FontStyles.Bold;
newForm.AddItem(b2);
Button b3 = Button.CreateNew();
b3.UniqueID = "4";
b3.Top = 565;
b3.Left = 270;
b3.Width = 110;
b3.Value = "NIEUWE OFFERTE";
b3.FontStyle = SwissAddonFramework.UI.Components.Item.FontStyles.Bold;
newForm.AddItem(b3);
newForm.Top = 100;
newForm.Width = 1150;
newForm.Left = 550;
newForm.Height = 625;
newForm.Value = "OVERZICHT TEMPLATE OFFERTES";
newForm.PaneLevel = 77;
newForm.Visible = true;
newForm.Load();
string query = @"SELECT 'Template offerte ' + rtrim(convert(char(8),T0.[DocNum])) + ' :' + T0.[Comments] as '> Templates', " +
" T1.[LineNum] as Lijn, T0.[DocEntry] as Offerte, T0.[DocDate] as Datum, T0.[CardCode] as Klant, T0.[CardName] as Klantnaam, " +
"T1.[ItemCode] as Artikel, T1.[Dscription] as Omschrijving, T1.[Quantity] as Aantal, T1.[Price] as 'Prijs', T0.[DocCur] as Munt " +
" FROM OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry " +
" WHERE T0.[Series] = 34 ";
grid.ExecuteQuery(query);
grid.Columns["> Templates"].Width = 225;
grid.Columns["Offerte"].Width = 45;
grid.Columns["Lijn"].Width = 25;
grid.Columns["Datum"].Width = 57;
//grid.Columns["Vervaldatum"].Width = 65;
grid.Columns["Klant"].Width = 63;
grid.Columns["Klantnaam"].Width = 135;
grid.Columns["Artikel"].Width = 50;
grid.Columns["Omschrijving"].Width = 300;
grid.Columns["Aantal"].Width = 45;
grid.Columns["Aantal"].RightJustified = true;
grid.Columns["Prijs"].Width = 80;
grid.Columns["Prijs"].FontStyle = SwissAddonFramework.UI.Components.GridColumn.FontStyles.Bold;
grid.Columns["Prijs"].RightJustified = true;
grid.Columns["Munt"].Width = 32;
grid.Columns["> Templates"].Editable = false;
grid.Columns["Offerte"].Editable = true;
grid.Columns["Lijn"].Editable = false;
grid.Columns["Datum"].Editable = false;
grid.Columns["Klant"].Editable = false;
grid.Columns["Klantnaam"].Editable = false;
grid.Columns["Artikel"].Editable = false;
grid.Columns["Omschrijving"].Editable = false;
grid.Columns["Aantal"].Editable = false;
grid.Columns["Prijs"].Editable = false;
grid.Columns["Munt"].Editable = false;
grid.CollapseLevel = 1;
grid.AffectsFormMode = false;
// Form die je oproept : 23 = Sales Quotation Object
((SwissAddonFramework.UI.Components.TextEditGridColumn)grid.Columns["Offerte"].SpecificGridColumn).LinkObjectType = "23";
newForm.Update();
----------
When i use the following code :
Grid m = Grid.GetFromUID(pVal.Form, "ICD_OQUTG1");
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Number of rows= " + m.Rows.Count, "INFO");
i know hw many rows are displayed on the screen,
but on what row my cursor is standing, i don't know.
I cannot use the pVal.Row because the system returns -1
thx,
Mario
Martin Ehrensberger
Hi Mario,In general, it's not possible to get the Rows and Columns of the cell currently in focus in a grid (when working with a button-event). It's only possible, to get the selectedRow.
If you want to work with a selection where you need to know the columns and rows (or want to run something out of a selection), you could use the KeyDown-event (pVal.charPressed) for example. So a user can click on a field of a grid, presses a button on the keyboard; and then lets your code run.
pVal.Row returns -1 because the event doesn't get called out of the grid. The button doesn't know the selection of the grid; it only knows the selected Row of the grid (only if a row is really selected).
Therefore an alternative would be, to use the selectedRow Property of the grid; this you can use in a button-event.
For further assistance on this issue, please call our support.
Regards,
Martin
0
Please sign in to leave a comment.
Comments
0 comments