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

GridDataBoundGrid Inheritance Designer issue

Hi, The GDBG displays all datasource columns by default. When you edit the gridboundcolumns collection there are no columns shown ? Where are the gridboundcolumns displayed ? It would be very easier to edit the list (just put the correct headertext) then to restart with a empty list. I was thinking of correcting this myself : 1. Overriden DataMember property 2. When changed and in DesignMode 3. Loop all DataColumns in DataSet and add this to the GridBoundColumnCollection (heading = DataColumn.Caption) This works but the gridcolumns are not serialized on the form. Any suggestions ?

5 Replies

AD Administrator Syncfusion Team October 25, 2005 05:07 PM UTC

If you do not explicitly populate GridBoundColumns, then you can use the grid.Binder.internalColumns collections to set properties, etc. But if you want to remove columns at runtime, you can use code like this: GriBoundColumnsCollection gbcc = this.grid.Binder.InternalColumns.Clone() as GriBoundColumnsCollection; //remove/add GridBoundColumns to gbcc. //then set them to be the used by the grid. grid.GridBoundColumns = gbcc; grid.Binder.InitializeColumns();


KM Krijn Michiels October 25, 2005 06:33 PM UTC

Thanks, but how can I populate gridcolumns at runtime through an inherited databoundgrid ? We use the datacolumn.caption field to store our column description.


AD Administrator Syncfusion Team October 25, 2005 07:05 PM UTC

I am not sure I understand. Why can''t you add a method named PopulateGridBoundColumns to the derived grid, and call that from the Load event of whatever form or usercontrol hosts the derived grid?


KM Krijn Michiels October 25, 2005 09:21 PM UTC

Having (very) much coding to do and lots of grids I don''t think that I want to click thousands of times on gridboundcolumns -> add -> change header text (already have this in DataColumn.Caption) -> ... Code I''m struggling with : Sub OnDataMemberChanged() If not DesignMode then Exit Sub gridBoundColumns.Clear() For each dc as DataColumn in Ctype(DataSource,DataSet).Tables(DataMember) Dim column as new GridBoundColumn column.MappingName = dc.ColumnName column.HeaderText = dc.Caption gridBoundColumns.Add(column) ''... Next The changed collection gridBoundColumns is not serialized in the parent form. Guess it has something to do with the PropertyDescriptor.


AD Administrator Syncfusion Team October 25, 2005 10:13 PM UTC

If what you want to do is to just display teh caption text as the header text for all columns, then the simplest thing to do is to handleModel.QueryCellInfo and swap the text at that point. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GDBG_VB_43760bfd.zip

Loader.
Live Chat Icon For mobile
Up arrow icon