We just started working with Essential Studio and our developer ran into an issue using the GridListControl. We present a list to the user for them to select a row and hit the Select button. The following code was implemented to read the value of the row the user selected. But instead of the selected row''s value we get "System.Data.DataRowView" returned. How do you get the value(s) from the selected row returned to the program?
Here is our current code:
Private Sub btnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelect.Click
Dim grd As DataGrid
Dim selind As Integer
Dim obj As Object
obj = Me.GridListControl1.SelectedItem()
selind = Me.GridListControl1.SelectedIndex
curprj = Me.GridListControl1.GetItemText(Me.GridListControl1.SelectedItem)
Me.Close()
End Sub
AD
Administrator
Syncfusion Team
April 26, 2005 12:01 AM UTC
Hi Bob,
Here is some code to get the selected values in GridListControl.
private void button1_Click(object sender, System.EventArgs e)
{
GridRangeInfoList list;
this.gridListControl1.Grid.Selections.GetSelectedRanges(out list, true);
foreach(GridRangeInfo range in list)
{
GridRangeInfo range1 = range.ExpandRange(1,1,this.gridListControl1.Grid.RowCount, this.gridListControl1.Grid.ColCount);
for(int i = range1.Top; i <= range1.Bottom; i++)
for(int j= range1.Left; j <= range1.Right; j++)
{
Console.WriteLine(this.gridListControl1.Grid.Model[i, j].Text.ToString());
}
}
}
Best Regards,
Jay N
BW
Bob Wis
April 26, 2005 12:30 PM UTC
Thanks Jay,
Thanks for the info. One question: It appears that your example is in C# and We are using VB.NET. We were wondering how you would accomplish the same thing in VB.NET?
Bob
AD
Administrator
Syncfusion Team
April 26, 2005 06:19 PM UTC
Hi Bob,
Here is the VB.NET code:
Dim list As GridRangeInfoList
Me.gridListControl1.Grid.Selections.GetSelectedRanges(list, True)
Dim range As GridRangeInfo
For Each range In list
Dim range1 As GridRangeInfo = range.ExpandRange(1, 1, Me.gridListControl1.Grid.RowCount, Me.gridListControl1.Grid.ColCount)
Dim i As Integer
For i = range1.Top To range1.Bottom
Dim j As Integer
For j = range1.Left To range1.Right
Console.WriteLine(Me.gridListControl1.Grid.Model(i, j).Text.ToString())
Next j
Next i
Next range
Best regards,
Jay N
BW
Bob Wis
April 26, 2005 11:03 PM UTC
Jay,
Thanks again. The code generates a build error that the GridRangeInfo and GridRangeInfoList types are not defined. Are we missing a Reference to one of the libraries?
Bob
AD
Administrator
Syncfusion Team
April 27, 2005 03:01 AM UTC
Hi Bob,
Please include this namespace:
Imports Syncfusion.Windows.Forms.Grid
Best regards,
Jay N