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.
Syncfusion Feedback

Strange behaviour with grid grouping events.

Thread ID:

Created:

Updated:

Platform:

Replies:

58905 Mar 30,2007 01:46 PM UTC Apr 2,2007 03:44 PM UTC Windows Forms 5
loading
Tags: GridControl
dinesh upreti
Asked On March 30, 2007 01:46 PM UTC

Hi,

I attached the following events to my grid. I am using grid grouping control. I have got a nested relationship in my grid.

private void gridGroupingControl1_TableControlCurrentCellKeyPress(object sender, GridTableControlKeyPressEventArgs e)
{

}

private void gridGroupingControl1_TableControlCellMouseDown(object sender, GridTableControlCellMouseEventArgs e)
{

}

Of these two, I am able to hit TableControlCurrentCellKeyPress but NOT TableControlCellMouseDown when i but a break point. Why is this so.

As a workaround i used

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{

}

I am able to hit that but the problem is that here in the event args 'e', I get th coordinated of the mouse clicked and not the row and col index of cell i clicked on. Please investigate and let me know.

haneefm [Syncfusion]
Replied On March 30, 2007 02:51 PM UTC

Hi Dinesh,

You can use the PointToRowCol method to find the RowIndex and ColIndex for a cell that is displayed at specified point. Here is a code snippet

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
int row, col;
if(e.TableControl.PointToRowCol(new Point(e.Inner.X, e.Inner.Y), out row, out col))
{
Console.WrtieLine( " RowIndex =>{0} : ColIndex=>{1}",row,col);
}
}

Best regards,
Haneef

dinesh upreti
Replied On March 30, 2007 04:17 PM UTC

thanks,
but the problem is that from row index and colindex, i want to access the record just as i can access e.TableControl.Table.CurrentRecord.GetData() which i can capture in cell key press event.;

so taking your approach, can i have a function to which i can pass the row index and col index to get the record back

Thanks

>Hi Dinesh,

You can use the PointToRowCol method to find the RowIndex and ColIndex for a cell that is displayed at specified point. Here is a code snippet

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
int row, col;
if(e.TableControl.PointToRowCol(new Point(e.Inner.X, e.Inner.Y), out row, out col))
{
Console.WrtieLine( " RowIndex =>{0} : ColIndex=>{1}",row,col);
}
}

Best regards,
Haneef

haneefm [Syncfusion]
Replied On March 30, 2007 07:37 PM UTC

Hi Dinesh,

You can try this code snippet to get a record in a grid.

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
int row, col;
if(e.TableControl.PointToRowCol(new Point(e.Inner.X, e.Inner.Y), out row, out col))
{
GridTableCellStyleInfo style = e.TableControl.Model[row, col] as GridTableCellStyleInfo;
if (style != null)
{
Element el = style.TableCellIdentity.DisplayElement;
if (el != null && el.Kind == DisplayElementKind.Record)
{
GridRecordRow recRow = el as GridRecordRow;
if (recRow != null)
{
Console.WriteLine(recRow);
}
}
}
}

Best regards,
Haneef

dinesh upreti
Replied On March 31, 2007 04:32 PM UTC

Thanks, the code snippent works fine for flat data.
But a big problem still remains. As i am mentioned earlier, i am working with nested relationships.

if (el != null && el.Kind == DisplayElementKind.Record)
{
GridRecordRow recRow = el as GridRecordRow;
if (recRow != null)
{
Console.WriteLine(recRow);
}
}

In the above condition, you are checking for DisplayElementKind.Record. What if DisplayElementKind is a Nested record. In that case recRow is null while there is a child record existing.
Just to mention, the specific problem i am working upon is that when user right clicks on a particular record(s) of set of child records, a right click menu pops up, so that from there, i will pass the selected or clicked record(s) to a function which will delete that record from data source.

haneefm [Syncfusion]
Replied On April 2, 2007 03:44 PM UTC

Hi Dinesh,

Please try this code.

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
Point pt = new Point(e.Inner.X, e.Inner.Y);
Element el = TableControl.PointToNestedDisplayElement(pt);
Record r = el.GetRecord(); //this will be the record in the nested table.
if ( r != null)
{
Console.WrtieLine(r);
}
}

Best regards,
Haneef

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.

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

;