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

Obtain datasource for a GridGroupingControl row given its rowId and columnId

Thread ID:

Created:

Updated:

Platform:

Replies:

67902 Sep 4,2007 01:35 PM UTC Sep 8,2007 02:11 AM UTC Windows Forms 1
loading
Tags: Grouping
José Manuel
Asked On September 4, 2007 01:35 PM UTC

Hello,

I'm using a modified version of the sample 4.1.0.50\Windows\Grid.Windows\Samples\CellTypes\LinkLabelCells to add link label cell support to a GridGroupingControl in Visual Studio 2005.

When a link label cell is clicked, I get rowId and columnId of the clicked cell, by a call to PointToRowCol function. RowId range is peculiar, as it starts with 1, and include header row, so record cells start at row #2.

I would like to access the dataRow bound to that cell, without using the CurrentCell property. That is, translate a rowId and columnId into that cell's bounded dataRowView; of course, taking possible sorting into account.

What I do now is substract 2 to the rowId and use this value to index the DataTable row collection directly, but it doesn't take sorting into account; and if sorting is carried out, this method fails to get the correct row.

By the way, is there any way to prevent a column of a GropingGridControl to allow sorting?

Thank you very much.
Jose M.

Rajagopal [Syncfusion]
Replied On September 8, 2007 02:11 AM UTC

Hi Jose,

Thanks for your interest in Syncfusion Products.

You can get the underlying datarowview of the clicked cell in the TableControlMouseDown event using the below code.

void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
Point pt = new Point(e.Inner.X, e.Inner.Y);
GridTableCellStyleInfo styleInfo = e.TableControl.PointToTableCellStyle(pt);
if (styleInfo.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
Record rec = styleInfo.TableCellIdentity.DisplayElement.GetRecord();
DataRowView drv = (DataRowView)rec.GetData();
foreach (object obj in drv.Row.ItemArray)
Console.Write(obj.ToString() + "\t");
Console.WriteLine();
}
}

To prevent a column from sorting in GridGroupingControl, use the TableControlQueryAllowSortColumn event and set e.AllowSort to false. Below is the code.

void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e)
{
if (e.Column.Name == columnName)
e.AllowSort = false;
}

Let me know if you have any other questions.

Regards,
Rajagopal

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

;