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.

GridDataBoundGrid and multiple selection

Thread ID:

Created:

Updated:

Platform:

Replies:

58466 Mar 23,2007 05:11 PM Mar 24,2007 10:47 AM Windows Forms 2
loading
Tags: GridControl
Rob Yang
Asked On March 23, 2007 05:11 PM

Hi, we have a GridDataBoundGrid in which we would like to be able to do the following :

1. User selects multiple rows.

2. User changes value of one of the cells.

3. Cell's new value is copied to all other cells in that column for the selected rows.

However, the problem we are seeing is in step 2 - when the user left-clicks into a textbox cell to change the value the multiple row selection is cleared and only that cell's row is selected. However, if the column is a combobox with dropdowns, then the new value can be selected without clearing the old row selections.

In this GDBG the ListBoxSelectionMode is set to MultiExtended. The grid.Model.Options.SelectCellsMouseButtonsMask is also set to MouseButtons.Left so as to enable context menu for multiple row selections.

We've tried GridModelOptions.ExcelLikeCurrentCell and MulitExtendedArrowKeySelect, but these don't seem to help. Is there any way to make this idea work ? Thanks for any assistance !

-Rob

Administrator [Syncfusion]
Replied On March 23, 2007 06:49 PM

Hi Rob,

This can be achieved by handling the Model.SelectionChanging event for keeping the existing selected ranges when pressing left mouse click and CurrentCellCahnged event for coping the current cell text to all selected cells in a grid. Please refer this sample and let me know if this helps.

void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
if (e.Reason == GridSelectionReason.MouseDown)
{
GridModel model = sender as GridModel;
GridRangeInfoList list = model.SelectedRanges;
foreach (GridRangeInfo range in list)
{
if (range.IntersectsWith(e.ClickRange))
e.Cancel = true;
}
}
}

void gridDataBoundGrid1_CurrentCellChanged(object sender, EventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridRangeInfoList list = grid.Model.SelectedRanges;

object objEditState = grid.CurrentCell.Renderer.GetEditState();
foreach (GridRangeInfo range in list)
{
for (int i = range.Top; i <= range.Bottom; i++)
{
for (int j = range.Left; j <= range.Right; j++)
{
grid.Model[i, j].CellValue = grid.CurrentCell.Renderer.ControlValue;
}
}
}
grid.CurrentCell.BeginEdit();
grid.CurrentCell.Renderer.SetEditState(objEditState);
}

Best regards,
Haneef

Rob Yang
Replied On March 24, 2007 10:47 AM

Thanks, that worked !
-Rob

--
>Hi Rob,

This can be achieved by handling the Model.SelectionChanging event for keeping the existing selected ranges when pressing left mouse click and CurrentCellCahnged event for coping the current cell text to all selected cells in a grid. Please refer this sample and let me know if this helps.

void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
if (e.Reason == GridSelectionReason.MouseDown)
{
GridModel model = sender as GridModel;
GridRangeInfoList list = model.SelectedRanges;
foreach (GridRangeInfo range in list)
{
if (range.IntersectsWith(e.ClickRange))
e.Cancel = true;
}
}
}

void gridDataBoundGrid1_CurrentCellChanged(object sender, EventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridRangeInfoList list = grid.Model.SelectedRanges;

object objEditState = grid.CurrentCell.Renderer.GetEditState();
foreach (GridRangeInfo range in list)
{
for (int i = range.Top; i <= range.Bottom; i++)
{
for (int j = range.Left; j <= range.Right; j++)
{
grid.Model[i, j].CellValue = grid.CurrentCell.Renderer.ControlValue;
}
}
}
grid.CurrentCell.BeginEdit();
grid.CurrentCell.Renderer.SetEditState(objEditState);
}

Best regards,
Haneef

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.

;