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.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

19321 Sep 23,2004 01:39 PM UTC Sep 29,2004 09:30 AM UTC Windows Forms 12
loading
Tags: GridControl
Devshi Halai
Asked On September 23, 2004 01:39 PM UTC

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.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On September 23, 2004 03:04 PM UTC

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

Devshi Halai
Replied On 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.

Administrator [Syncfusion]
Replied On 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

Devshi Halai
Replied On 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

Administrator [Syncfusion]
Replied On 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

Devshi Halai
Replied On 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

Administrator [Syncfusion]
Replied On 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

Devshi Halai
Replied On 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.

Devshi Halai
Replied On 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

Administrator [Syncfusion]
Replied On 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

Devshi Halai
Replied On September 29, 2004 09:30 AM UTC

Hi Stefan, That''s great all working.

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.

Warning Icon 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.Close Icon

;