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.

Select rows when clicked on the group

Thread ID:

Created:

Updated:

Platform:

Replies:

71736 Feb 11,2008 09:06 PM Feb 14,2008 01:50 AM Windows Forms 3
loading
Tags: GridControl
John Ruiz
Asked On February 11, 2008 09:06 PM

I'd want to select all the sub-rows/grouped rows when the user clicks on the parent grid caption section. I wrote the following piece of code but the same does not work for me. Please suggest if i am missing something?

This is invoked on TableControlMouseDown event and I am using Grid grouping control version
4.4.0.51

if (e.Inner.Button == MouseButtons.Left)
{
int rowIndex, colIndex;
Point point = new Point(e.Inner.X, e.Inner.Y);
Boolean validRowCol = gridGroupingControl.TableControl.PointToRowCol(point, out rowIndex, out colIndex);
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(rowIndex, colIndex);
GridCaptionSection gridCaptionSection = style.TableCellIdentity.DisplayElement as GridCaptionSection;

if (gridCaptionSection != null)
{
foreach (Record rec in gridCaptionSection.ParentGroup.Records)
{
rec.SetSelected(true);
}
}
}


SubhaSheela R [Syncfusion]
Replied On February 12, 2008 07:02 AM

Hi John,

Thank you for using Syncfusion products.

You could get the DisplayElement in GridCaptionRow instead of GridCaptionSection, which is used to get rows of the group caption. Below is the code snippet:

if (e.Inner.MouseEventArgs.Button == MouseButtons.Left)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
Element el = style.TableCellIdentity.DisplayElement;
GridCaptionRow gcr = style.TableCellIdentity.DisplayElement as GridCaptionRow;
if (gcr != null)
{
string s = "";
foreach (Record rec in gcr.GetCaptionSection().ParentGroup.Records)
{
s += "Id: " + rec.GetValue("id").ToString() + "\nItem: " + rec.GetValue("item").ToString() + " " + Environment.NewLine;
}
this.label1.Text = s.ToString();
}
}


Please refer to the sample available in the link below and let me know if it helps:

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

Regards,
Subhasheela R


John Ruiz
Replied On February 12, 2008 09:00 PM



>Hi John,

Thank you for using Syncfusion products.

You could get the DisplayElement in GridCaptionRow instead of GridCaptionSection, which is used to get rows of the group caption. Below is the code snippet:

if (e.Inner.MouseEventArgs.Button == MouseButtons.Left)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
Element el = style.TableCellIdentity.DisplayElement;
GridCaptionRow gcr = style.TableCellIdentity.DisplayElement as GridCaptionRow;
if (gcr != null)
{
string s = "";
foreach (Record rec in gcr.GetCaptionSection().ParentGroup.Records)
{
s += "Id: " + rec.GetValue("id").ToString() + "\nItem: " + rec.GetValue("item").ToString() + " " + Environment.NewLine;
}
this.label1.Text = s.ToString();
}
}


Please refer to the sample available in the link below and let me know if it helps:

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

Regards,
Subhasheela R




I don't understand but the cast of displayeLement to type GridCaptionRow works fine when invoked in TableControlCellClick but not when implemented in TableControlMouseDown. Why is the displayElement different for different events.

For TableControlMouseDown i get the row and column index via the point which is calculated on gridGroupingControl.TableControl.PointToRowCol function. What is the current function to get the valid row, col index for a given point then?


Jisha Joy [Syncfusion]
Replied On February 14, 2008 01:50 AM

Hi John,

If your intension is to select all the grouped rows when user click on the GridCaptionSection, this can be achieved by handling the TableControlCellClick event.

Please refer the following code snippets:

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{

Element el = this.gridGroupingControl1.Table.DisplayElements[e.Inner.RowIndex];
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex);
if (el.Kind == DisplayElementKind.Caption)
{
GridCaptionRow gcr = style.TableCellIdentity.DisplayElement as GridCaptionRow;
GridCaptionSection gcs = gcr.ParentSection as GridCaptionSection;
if (gcs != null)
{
foreach (Record rec in gcs.ParentGroup.Records)
{
rec.SetSelected(true);
}
}
}

}

Please refer the sample in the link to illustrate this:
http://websamples.syncfusion.com/samples/Grid.Windows/71736/main.htm

Kindly try this and let me know if you need further assistance.

Regards,
Jisha


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.

;