Hi,
I'm trying to configure a grid in an old winform application (using Infragistics 6.2) which restricts users to selecting multiple cells within a single column only. I'm able to set the grid to allow multiple cell selection (by setting SelectTypeCell property to Extended) but this allows a user to select multiple cells across one or more columns. How can I restrict multiple cell selection to one column only?
Thanks in advance,Assad
try this:
int ctr = 0;
private void ultraGrid1_BeforeSelectChange(object sender, Infragistics.Win.UltraWinGrid.BeforeSelectChangeEventArgs e)
{
if (ultraGrid1.Selected.Cells.Count <=1)
ctr = e.NewSelections.Cells[e.NewSelections.Cells.Count-1].Column.Index;
if(e.NewSelections.Cells.Count>0)
if (e.NewSelections.Cells[e.NewSelections.Cells.Count - 1].Column.Index != ctr)
e.Cancel = true;
}
Hi Hady,
This almost works. It works fine when trying to select multiple cells and dragging over columns to the right however when dragging over columns to the left, it still selects multiple cells in the left columns. I've managed to tweak your code to overcome this problem and added some additional checks. Note, I've also added the MouseUp event to reset the value of ctr. So far, this seems to work:
int ctr = -1;
private void grid_MouseUp(object sender, MouseEventArgs e) { ctr = -1; }
private void grid_BeforeSelectChange(object sender, BeforeSelectChangeEventArgs e) {
if (grid.Selected.Cells.Count <= 1 || (grid.Selected.Cells.Count > 1 && ctr == -1) ) { if (e.NewSelections.Cells.Count > 0) ctr = e.NewSelections.Cells[e.NewSelections.Cells.Count - 1].Column.Index; }
if (e.NewSelections.Cells.Count > 0) { if (grid.ActiveCell.Column.Index != ctr && ctr != -1) e.Cancel = true; }
Nonetheless, thanks for pointing me in the right direction.
Cheers,Assad