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

GridGroupingControl Finding the column name for the column cell in a multi row record

How can I find the correct column index or column name for a multi-row record header when a cell with the column header in the second or more row header has been clicked. GridGrouping_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e) { int colIndex = e.TableControl.CurrentCell.ColIndex; int rowIndex = e.TableControl.CurrentCell.RowIndex; // the colIndex returned is for only the top header row. } I want to get the correct column name or colum index for all columns in all multi-record row headers.

12 Replies

AD Administrator Syncfusion Team September 23, 2004 03:03 PM UTC

Hi Dan, use the cell styles identity. This has the column descriptor. GridGrouping_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e) { int colIndex = e.TableControl.CurrentCell.ColIndex; int rowIndex = e.TableControl.CurrentCell.RowIndex; // Get the style GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; // The identity contains all information about group, column, displayelement etc. GridColumnDescriptor column = style.TableCellIdentity.Column; // To get the relative row/col for for a column descriptor in multi-row scenarion: int resultCol, resultRow; e.TableControl.TableDescriptor.ColumnToRowColIndex(column.Name, out resultRow, out resultCol); } Stefan


AD Administrator Syncfusion Team September 23, 2004 03:04 PM UTC

e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; should be e.TableControl.Model[rowIndex, colIndex]; ... Stefan


DH Devshi Halai September 24, 2004 04:57 AM UTC

Hi, Stefan Thanks for the reply. I''ve tried what you''ve suggested, I wonder if there may be a bug in the Syncfusion v2.1.0.9 as I''m not able to get a valud Column in TableCellIdentity. This is undefined, so I''m unable to get a valid GridColumnDescriptor in the following code segment. GridColumnDescriptor column = style.TableCellIdentity.Column; Thanks Dev.


AD Administrator Syncfusion Team September 24, 2004 09:57 AM UTC

It will be null when the queried cell is not dependant on a column. For example, the topleft header cell, row header cells or plus-minus cells are not associated with colums and therefore column will be null. Stefan


DH Devshi Halai September 24, 2004 10:43 AM UTC

Hi Stefan, The queried cell I''m changing is a column dependant cell where I can enter data (textbox). Any help with this is appreciated. Thanks Dev


AD Administrator Syncfusion Team September 24, 2004 11:23 AM UTC

Doesn''t make sense ... If it would be null then you would not be able to edit text in the column. What does TableCellIdentity.Info / TableCellIdentity.ToString() return when you call it? Thanks, Stefan


DH Devshi Halai September 24, 2004 01:06 PM UTC

Hi Stefan, Sorry about last post, but Column now has a value. However the value I get is not for the correct column, Its for another column in the grid. I''m using GridColumnSetDescriptor with GridColumnSpanDescriptor to create a mutli-row header. Any way in which I can get the correct Column Name ? The output I get from TableCellIdentity.ToString() is "Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoIdentity {rowIndex = 9, colIndex = 3 } {AlternateRecordFieldCell, Column = Strategy, DisplayElement = GridRecordRow, , Table = GridTable (ArrayList) }" However the column is not the one that I changed


AD Administrator Syncfusion Team September 24, 2004 03:19 PM UTC

Can you create a small sample (e.g. modify the EmployeeView sample) so that it shows the problem you have? Thanks, Stefan


DH Devshi Halai September 27, 2004 05:48 AM UTC

Hi Stefan, I added the following code to the Employee View Sample, with the // Initializer this.gridGroupingControl1.TableControlCurrentCellChanged += new GridTableControlEventHandler(gridGroupingControl1_TableControlCurrentCellChanged); //Event handler private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e) { int colIndex = e.TableControl.CurrentCell.ColIndex; int rowIndex = e.TableControl.CurrentCell.RowIndex; // Get the style GridTableCellStyleInfo style = e.TableControl.Model[colIndex, rowIndex]; // The identity contains all information about group, column, displayelement etc. GridColumnDescriptor column = style.TableCellIdentity.Column; // To get the relative row/col for for a column descriptor in multi-row scenarion: int resultCol, resultRow; e.TableControl.TableDescriptor.ColumnToRowColIndex(column.Name, out resultRow, out resultCol); } I performed the following tests: click in a cell change the value and the check the value of column.Name with the following results: 1. CellChanged - "FirstName", column.Name - "City" 2. CellChanged - "LastName", column.Name - "PostalCode" 3. CellChanged - "Address", column.Name - "Address" 4. CellChanged - "City", column.Name - "Address" 5. Cellchanged - "PostalCode", column.Name - "PostalCode" 6. CellChanged - "Region", column - undefined value. In most cases the Cell being changed is not being correctly reflected in the event handler. Thanks Dev.


DH Devshi Halai September 29, 2004 08:50 AM UTC

Hi Stefan, I''ve got a sample project which higlights the problem. This has more columns than the employee view sample. I''m using Syncfusion Essential Suite 2.1.0.9 and VS.NET 2003 When I change data cell "C1" , In the gridGrouping_TableControlCurrentCellChanged event hander, the GridColumnescriptor column.Name is set to "C5", when it should be "C1". Can you please let me know what you think the issue is. I''m not able to use the VS.NET Designer to set up the grid properties as the designer is not able to load the Syncfusion.Grid.Grouping control into the VS.NET designer toolbox. ColumnTest_8573.zip


AD Administrator Syncfusion Team September 29, 2004 09:12 AM UTC

Hi Dev, in your CurrentCellChanged handler you have the following line: GridTableCellStyleInfo style = e.TableControl.Model[colIndex, rowIndex]; Just replace it with the correct order of row/colindex: GridTableCellStyleInfo style = e.TableControl.Model[rowIndex, colIndex]; Then it should be fine. Same problem is in both your samples. Stefan


DH Devshi Halai September 29, 2004 09:30 AM UTC

Hi Stefan, That''s great all working.

Loader.
Live Chat Icon For mobile
Up arrow icon