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.
Unfortunately, activation email could not send to your email. Please try again.

Get underlying data by mouse event in GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

72369 Mar 16,2008 09:10 PM Apr 9,2008 02:20 AM Windows Forms 4
loading
Tags: GridControl
Harry
Asked On March 16, 2008 09:10 PM

Hello,

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?

Thanks,
Harry


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

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:

'>http://www.syncfusion.com/support/forums/message.aspx?MessageID=13296">
http://www.syncfusion.com/support/forums/message.aspx?MessageID=13296

Please let me know if you have any questions.

Regards,
Subhasheela R




Harry
Replied On March 17, 2008 07:27 AM

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,
Harry


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

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")
printSelectedRecords(table)
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:


http://websamples.syncfusion.com//samples/Grid.Windows/F72369/main.htm


Regards,
Subhasheela R



Harry
Replied On April 9, 2008 02:20 AM

Dear Subhasheela:

Thanks, it's perfect.
Harry



CONFIRMATION

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.

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.

;