Accessing matrix on new form created
Mario Byttebier
Hi,i have created a new form, using a query to create a matrix. (grid)
When i put my cursor on a line, i want to use a button to do something else.
Therefore i need to have the row information of some fields.
To create my new form i used this code with new menu :
----------------------------------------------------------
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 = 535;
newForm.AddItem(grid);
Button b1 = Button.CreateNew();
b1.UniqueID = "1";
b1.Top = 585;
b1.Left = 20;
b1.Value = "OK";
newForm.AddItem(b1);
Button b2 = Button.CreateNew();
b2.UniqueID = "3";
b2.Top = 585;
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 = 585;
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 = 650;
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', T0.[DocNum] as Offerte, " +
" T1.[LineNum] as Lijn, 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.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();
---------------------
To select the row information, i used this code, via a button-itempressed :
-----------------------
MessageBox.Show("Selectie TEMPLATE-offerte !!! " , "OK");
try
{
if(pVal.InnerEvent) return true;
Matrix m = Matrix.GetFromUID(pVal.Form, "ICD_OQUTG1");
bool bOk;
string Offerte = m.GetValue("Offerte", pVal.Row-1);
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Offerte= " + Offerte , "INFO");
string Lijn = m.GetValue("Lijn", pVal.Row-1);
SwissAddonFramework.UI.Dialogs.MessageBox.Show("Lijn= " + Lijn , "INFO");
}
catch(System.Exception exe)
{
MessageBox.Show("Exception : " + exe.Message, "OK");
}
return true;
-----------------------
When i click on the button, i get an error screen, as you see in the attachment.
What am i doing wrong ?
thx,
Mario
Attachment
[url=http://www.coresystems.ch/wp-content/../wp-content/forum-image-uploads/mbyttebiericorda-be/Capture.JPG]Capture.JPG[/url]
Michael Egloff
Hello Mario,the error happens here:
Matrix m = Matrix.GetFromUID(pVal.Form, "ICD_OQUTG1");
it's not a matrix, it's a grid, you've created before. Therefore you have to use it like a grid:
Grid m = Grid.GetFromUID(pVal.Form, "ICD_OQUTG1");
Mario Byttebier
Michael,thanks for your answer.
Is it possible to capture the current row on this grid ?
thx,
Mario
0
Please sign in to leave a comment.
Comments
0 comments