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

Help with rowindex,colindex from SelectedRecordsChanging event of ggc

How do I get the rowIndex and colIndex from the SelectedRecordsChanging event.

I have tried ...

GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
int rowIndex = cc.RowIndex;
int colIndex = cc.ColIndex;

... but this fails when the the current cell is a ComboBox.



I have also tried ...

string tName = e.Table.TableDescriptor.Name;
GridGroupingControl grid = sender as GridGroupingControl;
GridTableControl tc = grid.GetTableControl(tName);

//Disallow selection from colIndex is greater than 8
bool bSuccess = grid.TableControl.PointToRowCol(grid.PointToClient(MousePosition), out row, out col);
if (bSuccess && col > 8){
e.Cancel = true;
return;
}

//Disallow selection for disabled rows
e.Cancel = !tc.Table.GetTableCellStyle(row, col).Enabled;

but it is always failing, returning -1 for both row and col.


What I am trying to achive is to prevent selection when
1. the row is disabled
2. the current cell column index is greater than 8

3 Replies

AD Administrator Syncfusion Team March 15, 2007 08:39 PM UTC

Hi James,

Thank you for being patience.

A simple way is to handle the QueryCellStyleInfo event and set a Boolean variable for the cell style is enabled. Depending on which the selection of records can be canceled. Please try the following code snippet.
>>>>>>>>>>Code Snippet<<<<<<<<<
bool flag = false;
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
if (e.TableCellIdentity.RowIndex > 7)
e.Style.Enabled = false;
else if (e.TableCellIdentity.ColIndex > 8 || !e.Style.Enabled)
flag = true;
else
flag = false;
}
}

void gridGroupingControl1_SelectedRecordsChanging(object sender, Syncfusion.Grouping.SelectedRecordsChangedEventArgs e)
{
e.Cancel = flag;
}
>>>>>>>>>>Code Snippet<<<<<<<<<

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan


JB James Blibo March 16, 2007 02:05 PM UTC

I would rather stay away from the QueryCellStyleInfo event. I just need to get the column and row index from within this event.


JB James Blibo March 20, 2007 08:10 PM UTC

Any update on getting the rowindex and colindex from the SelectionChanging event? I do not want to use the QueryCellStyleInfo event...

Loader.
Live Chat Icon For mobile
Up arrow icon