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
close icon

From KB: How can I set/change Back Color of a Selection?

Hi,
Found the KB article above, but I want to set the SelectionBackColot of a nested table. Using the example MultipleRecordSelection_2005 and the property dialog, setting the CustomersOrders.TableOptions.SelectionBackColor has no effect. How best to do this?

Im using 4.2.0.37 in VS2005 if that helps.
Thanks
John

6 Replies

AD Administrator Syncfusion Team January 3, 2007 10:27 AM UTC

Hi John,

Before set the TableOptions.SelectionBackColor property, you should set the TableOptions.ListBoxSelectionColorOptions to GridListBoxSelectionColorOptions.ApplySelectionColor. The ListBoxSelectionColorOptions property to control the backcolor and textcolor of the selected cell in PrepareViewStyleInfo event.

Let me know if this helps.
Best Regards,
Haneef


AD Administrator Syncfusion Team January 3, 2007 10:38 AM UTC

Hi Haneef,
The TableOptions.ListBoxSelectionColorOptions of the grid and of the CustomerOrders TableDescriptor is already ApplySelectionColor in your example.
Are you saying I need to handle the PrepareViewStyleInfo event to set the selected background color for the nested table?

Thanks
John

>Hi John,

Before set the TableOptions.SelectionBackColor property, you should set the TableOptions.ListBoxSelectionColorOptions to GridListBoxSelectionColorOptions.ApplySelectionColor. The ListBoxSelectionColorOptions property to control the backcolor and textcolor of the selected cell in PrepareViewStyleInfo event.

Let me know if this helps.
Best Regards,
Haneef


AD Administrator Syncfusion Team January 3, 2007 12:45 PM UTC

Hi John,

I have tested this issue in MultiRecordSelection browser sample with Essentail studio V.4.2.0.37 and 4.x. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. The attached video clip shows the record being selected without issues in Essentail studio v4.2.0.37.If you can provide more information, we can try to suggest some solution.

Video clip : selectionColor.zip

Regards,
Haneef


JH John H January 3, 2007 01:25 PM UTC

Hi Haneef,
Thanks for the video, but that's not what I mean. :)

Using your example, if the user selects the ANTON customer row, I want it to display Red.
but if the select a CustomerOrder row, I want it Blue.

Hope this helps.

Thanks
John



>Hi John,

I have tested this issue in MultiRecordSelection browser sample with Essentail studio V.4.2.0.37 and 4.x. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. The attached video clip shows the record being selected without issues in Essentail studio v4.2.0.37.If you can provide more information, we can try to suggest some solution.

Video clip : selectionColor.zip

Regards,
Haneef


AD Administrator Syncfusion Team January 4, 2007 09:20 AM UTC

Hi John,

One way you can do this by handling the QueryCellStyleInfo event and set backcolor for the selected records in a grid. Also you need to turn off the default selection color using TableOptions.ListBoxSelectionColorOptions property. Here is a code snippet to show this.

//Form Load..
this.gridGroupingControl1.TableOptions.ListBoxSelectionColorOptions = GridListBoxSelectionColorOptions.None;

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
Element el = e.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record)
{
GridRecordRow row = el as GridRecordRow;
GridTable table = e.TableCellIdentity.Table;

if( table != null && table.TableDescriptor != null
&& table.SelectedRecords.Contains(row.ParentRecord))
{
switch(table.TableDescriptor.Name)
{
case "Customers" :
e.Style.BackColor = Color.Red;
break;
case "Orders":
e.Style.BackColor = Color.Blue;
break;
default:
e.Style.BackColor = Color.Green;
break;
}
}
}
}

Best Regards,
Haneef


JH John H January 4, 2007 10:50 AM UTC

Hi Haneef,
Thanks for the code, looks like that will do what I want.
However, I think that;
TableOptions.SelectionBackColor = Color.Blue;
Should work on the embedded table, I would even go further to say that it is a bug or at the very least a design oversight that it doesn't. Why have TableOptions on child tables that aren't actually used? Why should I have to write events to do this when properties already exist that should do this for me? Let me know what you think.

Regards
John

Loader.
Live Chat Icon For mobile
Up arrow icon