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. Image for the cookie policy date

Clearing the selection in GridGroupingControl.

Hi,

I have GridGroupingControl version 4.2.0.60 in a .NET windows application. I am highlighting the whole record programmatically.Below is the code snippet to achieve this selection.

grid_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) {
e.Inner.Style.Interior = highlightRowBrush;
e.Inner.Style.TextColor = SystemColors.HighlightText;

The grid is grouped on some column.I click on the cell(say c1), the whole record containing that cell is highlighted . Now click on the group header and click on the other cell(say c2). Now the previously selected record(record of cell c1) will still be highlighting and also the currently selected(record of cell c2). Grid looks like having multiple selections. Please let me know the properties I need to set to clear the previous selection.

Regards,
Manjula.

6 Replies

JS Jeba S Syncfusion Team March 27, 2007 05:45 AM UTC

Hi Manjula,

Please try this code snippet to highlight the whole record and to avoid the previous selection.

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
// Highlight the current row with SystemColors.Highlight and bold font
if (e.Inner.RowIndex > 3 && e.Inner.ColIndex > 0 && cc.HasCurrentCellAt(e.Inner.RowIndex))
{
e.Inner.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Inner.Style.TextColor = SystemColors.HighlightText;
e.Inner.Style.Font.Bold = true;
}
}


Kindly let us know if this helps.

Best Regards,
Jeba.


MB Manjula Boudannavar March 27, 2007 10:03 AM UTC

Hi,

Thanks for your response. Its working. I am highlighting the row with the blue colour and it also highlights the cell with the blue colour which I dont want. The cell I click on should have the background colour white(The selection should not highlight the cell) Please see the attached snapshot.

Please let me know which properties I need to set or any other approach would do.

Regards,
Manjula.

SnapShot2.zip


JS Jeba S Syncfusion Team March 28, 2007 04:04 AM UTC

Hi Manjula,

Please try this code snippet to highlight the row and the current cell with white background.

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One
gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None
gridGroupingControl1.TableOptions.SelectionBackColor = Color.Pink
gridGroupingControl1.TableOptions.SelectionTextColor = Color.SteelBlue
gridGroupingControl1.TableOptions.ListBoxSelectionColorOptions = GridListBoxSelectionColorOptions.ApplySelectionColor


Kindly let us know if this helps.

Best Regards,
Jeba.


MB Manjula Boudannavar March 28, 2007 11:04 AM UTC

Hi,

I want to have the event grid_TableControlPrepareViewStyleInfo and highlight the row programmatically not by setting any properties. But the cell I click on should have white background as explained before.

Please let me know what code or any proeprties I need to set to have that behaviour.

Thanks and Regards,
Manjula.


MB Manjula Boudannavar April 5, 2007 09:22 AM UTC

Hi,
Do you have any suggestion. Please let me know.

Regards,
Manjula.


HA haneefm Syncfusion Team April 5, 2007 07:57 PM UTC

Hi Manjula,

Please try this code.

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if( style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record )
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if( cc.RowIndex == e.Inner.RowIndex
&& cc.ColIndex == e.Inner.ColIndex)
{
e.Inner.Style.BackColor = Color.White;
e.Inner.Style.TextColor = Color.White;
}
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon