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

Assigning Column Names

Is there any way for a GridControl that is not bound to have associated column names. In my case, it would be easier for me if I could refer to columns by name instead of having to track them by index and manage those associations as the users shuffle their locations. Any suggestions.

2 Replies

AD Administrator Syncfusion Team March 16, 2004 02:23 PM UTC

There is no built-in support for named columns in a GridControl. You will have to write some code to handle this. There are some virtual methods in GridModel, like NametoColIndex, that can be used to hook into to supportting named columns. But you still have to implement this virtual method that maps names to colindexes. And if your user shuffles the columns, you have to have some way that that your override is aware of this, and handles things for you. (Ie, you still have to track things somehow). One approach would be to stuff the name in a header cell property (maybe like, model[0, col].Description). Then when your user shuffles the columns, the name geys shuffled also. Then in your NameToColIndex override, you could loop through the header cells to find the description to return the colindex. If you have our source code, you can see this type of behavior implemented for the GridDataBoundGrid in the GridModelDatabinder class which uses teh GridBoundColumns collection to track mappingnames.


AJ Aaron Jackson March 16, 2004 02:57 PM UTC

Okay, thats about what I thought. Thanks for the heads up.

Loader.
Live Chat Icon For mobile
Up arrow icon