We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get underlying data by mouse event in GGC

Thread ID:





72369 Mar 17,2008 01:10 AM UTC Apr 9,2008 06:20 AM UTC WinForms 4
Tags: GridControl
Asked On March 17, 2008 01:10 AM UTC


I wish get underlying data in Gridgroupingcontrol by this code:

Sub gc_TableControlMouseDown()
Dim pt As Point = New Point(e.Inner.Location.X, e.Inner.Location.Y)
Dim gtc As GridGroupingControl = sender
Dim el As Element = gtc.PointToNestedDisplayElement(pt)
Dim ParentName As String = el.ParentTableDescriptor.Name
Dim cm As CurrencyManager = ggBusiness.GetTable(ParentName).GetCurrencyManager
Dim dv As DataView = cm.List
End Sub

The problem is that: PointToNestedDisplayElement is not member of GridGroupingControl.
Please advise me how to work around this?


Administrator [Syncfusion]
Replied On March 17, 2008 08:09 AM UTC

Hi Harry,

Thank you for using Syncfusion products.

You can get the underlying DataRow when you call r.GetData(). That will return the DataRowView element for the record. You can get at the currentcell using gridGroupingControl1.TableControl.CurrentCell. You can refer the below forum thread for more details.

Here is the forum thread link:


Please let me know if you have any questions.

Subhasheela R

Replied On March 17, 2008 11:27 AM UTC

Dear Subhasheela:

1. I tried to translate the code from C to VB but got error.
Dim el As Element = ggc.TableControl.Table.CurrentElement
Dim rec As Record = Nothing
Dim TableName As String = vbNullString
Dim drv As DataRowView = Nothing
Dim col As Integer = 0
Dim field As Integer = 0
Dim o As Object = Nothing
If Not IsNothing(el) Then
If el.Kind = DisplayElementKind.Record Then
rec = el.GetRecord
drv = CType(el.GetData, DataRowView)
TableName = el.ParentTableDescriptor.Name
col = ggc.TableControl.CurrentCell.ColIndex
field = ggc.TableDescriptor.ColIndexToField(col)
o = rec.GetValue(ggc.TableDescriptor.Fields(field))
ElseIf el.Kind = DisplayElementKind.NestedTable Then

Dim gnt As GridNestedTable = el
Dim gnt1 As GridNestedTable = gnt
While Not IsNothing(gnt1) AndAlso Not IsNothing(gnt1.ChildTable)
gnt = gnt1
gnt1 = gnt.ChildTable.ParentTable.CurrentElement
End While
rec = gnt.ChildTable.ParentTable.CurrentRecord
drv = CType(gnt.GetData, DataRowView)

TableName = gnt.ChildTable.ParentTable.TableDescriptor.Name
Dim tableControl As GridTableControl = ggc.GetTableControl(TableName)
col = tableControl.CurrentCell.ColIndex
field = gnt.ChildTable.ParentTable.TableDescriptor.ColIndexToField(col)
o = rec.GetValue(gnt.ChildTable.ParentTable.TableDescriptor.Fields(field))
End If
End Sub

Error on:
gnt1 = gnt.ChildTable.ParentTable.CurrentElement --> invalidcastexception: Unable to cast object type GridRecordWithValueCache to type GridNestedTable

Kindly advise, how to fix it?
Since there are some visible columns removed in the table, the column index was incorrect.

2. I tried to column info by mouse down event, but this code only work on parent table, it didn't work on nested tables:
Dim pt As Point = New Point(e.Inner.Location.X, e.Inner.Location.Y)
Dim el As Element = ggBusiness.TableControl.PointToNestedDisplayElement(pt)
Dim row As Integer
Dim col As Integer
ggBusiness.TableControl.PointToRowCol(pt, row, col, -1)
Dim Column As GridColumnDescriptor = e.TableControl.Table.GetColumnDescriptorAt(row, col)

'Column' value is 'Nothing' at nested table, how to work it out correctly?

Best Regards,

Administrator [Syncfusion]
Replied On March 27, 2008 10:54 AM UTC

Hi Harry,

Extremely sorry for the long delay in getting back to you.

With the nested tables, you need to get the child table you want, for getting the selected rows. Here is a code snippet:

Dim table As Syncfusion.Windows.Forms.Grid.Grouping.GridTable = Me.GridGroupingControl1.Table
Console.WriteLine("The " & table.TableDescriptor.Name & " selected records")
For Each rt As Syncfusion.Grouping.Table In table.RelatedTables
Console.WriteLine("The " & rt.TableDescriptor.Name & " selected records")
printSelectedRecords(TryCast(rt, Syncfusion.Windows.Forms.Grid.Grouping.GridTable))
Next rt

Kindly have a look into the sample available in the link below and please let me know if it helps:


Subhasheela R

Replied On April 9, 2008 06:20 AM UTC

Dear Subhasheela:

Thanks, it's perfect.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon