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

How to convert ColIndex into a column name for a GridControl?

Hi,
I have asked this question before for the GGC, but now I need to do it for a GridControl within the PrepareViewStyleInfo event. Do you have any examples? I cant find a TableDescriptor for the GridControl.

Thanks
John

4 Replies

AD Administrator Syncfusion Team March 5, 2007 03:57 PM UTC

Actually to be more specific, how do I convert the RowIndex and ColIndex within the PrepareViewStyleInfo event of a GridControl to the actual row and column indexes of the underlying dataset?

Thanks
John


AD Administrator Syncfusion Team March 5, 2007 04:05 PM UTC

Hi John,

For GridControl:

Call the GetAlphaLabel method to get the column labels in a grid. Here is a code snippet

string strColumnName = GridRangeInfo.GetAlphaLabel(e.ColIndex);

For DataBoundGrid:

Use InternalColumn collection property to get the column name of the grid. Below is a code

string strColumnName = this.gridDataBoundGrid1.Binder.InternalColumns[e.ColIndex].MappingName;

Best Regards,
Haneef


JH John H March 6, 2007 11:04 AM UTC

Hi Haneef,

Sorry Im not sure how this works:
GridRangeInfo.GetAlphaLabel(e.ColIndex);

Is GridRangeInfo a property of the grid? do I need to get the current selection and create a GridRangeInfo for it?
Sorry I think Im being a bit dim today.

Thanks
John


JH John H March 6, 2007 11:12 AM UTC

Hi Haneef,
I found an example, its quite obvious really. :-)

http://www.syncfusion.com/support/evalcenter/viewsource.aspx?&zip_path=115_Header_Text_-_Rows,_Columns_src.zip&lang=csharp&id=115

Basically just use;
gridControl[0, e.ColIndex].Text;

Thanks
John

Loader.
Live Chat Icon For mobile
Up arrow icon