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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

54151 Jan 3,2007 09:57 AM UTC Jan 4,2007 10:50 AM UTC WinForms 6
loading
Tags: GridControl
John H
Asked On January 3, 2007 09:57 AM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

John H
Replied On 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

Administrator [Syncfusion]
Replied On 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

John H
Replied On 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

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

;