When I attach to a DataTable, I am expecting the column header to reflect the DataColumn.Caption property. It seems that this should be okay, but the grid seems to be displaying the DataColumn.ColumnName (which, per the docs is what is returned if the Caption property is not explicitly set) rather than the value of the Caption property. Am I missing something or is this designed behavior?
I just checked the MS DataGrid and it ignores the property too...just _seemed_ like this is what that property of the DataColumn should be used for...
I can get the value to work okay with the GridBoundColumn.HeaderText property, but wanted to keep this type of business logic (IMHO) seperated from the UI if possible and only have to have it at the source of the information.
Thanks in advance for any responses...
ADAdministrator Syncfusion Team August 9, 2003 04:52 PM
The databinding supports any IList or IListSource object. The only information for such general data source is the PropertyDescriptor. So, the HeaderText is initialized with the PropertyDescriptor.Name property. This is why things work as they do in a GridDataBoundGrid and in a DataGrid.
That said, it would be possible to add checks for particular datasources to make use of additional properties that might be available. But just changing this functionality at this point would break the behavior of existing code. So, any changes would have to be implemented on a conditional basis.
As a workaround, you could add the method below to your form and just call it after you set the datasource to the grid. This would allow you to control the headers just by setting the column captions.
Thanks Clay, I figured as much, but it never hurts to ask! ;>) Thanks for the snippet too. I modified a bit to set a flag to see if the refresh was required, e.g. were any column headers actually changed.