VisibleColumn index and Column index

Hi,

I have a GGC which is bound to a business object via complex databinding. In some special cases it is necessary to hide some columns. I found out that this can be done via the TableDescriptor.VisibleColumns.Remove(..) or .Add(..) method.

Now I am wonder what happens to the column indizies in this case. So for example when I use the TableControlCellClick event, one EventArg property is the column index. Now when i want to get the corresponding column (which was clicked) then usually I do something like this:

int fieldIndex = gridGroupingControl1.TableDescriptor.ColIndexToField(e.Inner.ColIndex);
string name = gridGroupingControl1.TableDescriptor.Columns[fieldIndex].Name;

But this doesn't work when I set the VisibleCoumns property of the TableDescriptor. Then I have to replace the two lines above with:

int fieldIndex = gridGroupingControl1.TableDescriptor.ColIndexToField(e.Inner.ColIndex);
string name = gridGroupingControl1.TableDescriptor.VisibleColumns[fieldIndex].Name;

So how do I know if I should use the .VisibleColumns or the .Columns - Is there a way to get always the right column without knowing if one should use VisibleColumn or Column?

And how can I get the GridColumnDescriptor of a GridVisibleColumnDescriptor?

Cheers,
Franz


2 Replies

FG Franz Gsell September 20, 2007 11:50 AM UTC

Just a try: would it be correct to do something like this:

int fieldIndex = tableControl.TableDescriptor.ColIndexToField(this.ColIndex);
GridVisibleColumnDescriptor visibleDescriptor = tableControl.TableDescriptor.VisibleColumns[fieldIndex];
GridColumnDescriptor colDescriptor = tableControl.TableDescriptor.Columns[visibleDescriptor.Name];

to get the corresponding GridColumnDescriptor?

The handling of the column indizies is a little bit confusing.


J. J.Nagarajan Syncfusion Team September 20, 2007 11:11 PM UTC

Hi Franz,

The GridColumnDescriptor provides the mapping information to a column of the underlying datasource. All the columns from the datasource are managed by the GridColumnDescriptorCollection that is returned by the GridTableDescriptor. Whereas, the GridVisibleColumnDescriptor refrences the GridColumnDescriptor, but this defines the order of columns shown in the grid from left to right.

What you have tried in earlier update is fine. You can go ahead with this.

Please let me know if you need more information.

Regards,
Nagaraj

Loader.
Up arrow icon