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

GDBG Custom Color Multi Select Problem

Hello!
Q1. I have figured out how to change selection color in my GDBG in ListBoxSelectionMode = SelectionMode.One.
There I used grid.AlphaBlendSelectionColor = Color.FromArgb(0, grid.AlphaBlendSelectionColor) to get rid of AlfaBlend colors and use my selection color. But when I switch to ListBoxSelectionMode = SelectionMode.MultiExtended the multi selection did not seem to work. When I commented out the above line the selection worked but used AlfaBlend color. So how can I use custom selection color for SelectionMode.MultiExtended?
Attached is the problem sample code.

Q2. In SelectionMode.MultiExtended when I move mouse (with left button down) multiple rows get selected. It is not a wanted behavior. What event should I handle in GDBG to cancel the selection.

Please help. Thanks a lot!


GDBGMultiSelectColor.zip

2 Replies

AD Administrator Syncfusion Team December 5, 2006 12:19 PM UTC

Hi Ivan,

Regarding Question 1:

Please try this code

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (this.gridDataBoundGrid1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Row(e.RowIndex)))
{
e.Style.BackColor = selection_color;
e.Style.TextColor = SystemColors.HighlightText;
}
}

Regarding Question 2:

You can handle the Model.SelectionChanging event and set e.Cancel to TRUE to cancel the selection when the mouse move over the cell. Here is a code snippet

//Form Load event.
this.gridDataBoundGrid1.Model.SelectionChanging += new GridSelectionChangingEventHandler(Model_SelectionChanging);

void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
if (e.Reason == GridSelectionReason.MouseMove)
e.Cancel = true;
}

Here is a modified sample.
GDBGMultiSelectColor.zip

Best Regards,
Haneef


IM Ivan Moskvic December 5, 2006 08:10 PM UTC

Works now... Thanks a lot!!

Loader.
Live Chat Icon For mobile
Up arrow icon