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

Date display in data bound grid

I am using the db grid to display some info that contains date fields. The grid defaults to showing these dates with a "button" that activates a date picker. I''d like to supress the button and just have the date read-only Jim Frisby conocophillips.com

4 Replies

AD Administrator Syncfusion Team July 26, 2004 10:23 PM UTC

You can just hide the button by setting style.ShowButtons = Hide for that GridBoundColumn. You can also set style.ReadOnly = true for the column. Or, another option would be to set style.CellType = "Static" for the GridBoundColumn. GridStyleInfo style = this.grid.Binder.InternalColumns["TheDateCol"].StyleInfo; style.CellType = "Static"; style.CellValueType = typeof(DateTime); style.Format = "MM/dd/yyyy"; This code assumes you have not explicitly added GridBoundColumns to teh grid. If you have, then use style = grid.GridBoundColumns["TheDateCol"].StyleInof to get the style object for the column.


JA James A Frisby(For EPS - Computer Software) July 27, 2004 03:20 PM UTC

Clay, I tried several of these options, I would like to set the whole grid (all the columns) to read only, as I''m editing and creating records on another form, however, when I try to access the "GridBoundColumn" collection, it''s empty. I haven''t explicitly added any columns, just bound a dataset to the grid. I also tried to iterate all the cells in the grid (with bound data) trying to set showbutton to "hide", and trying to set the cells to readonly. it doesn''t raise an error, but it doesn''t change the property either. Jim >You can just hide the button by setting style.ShowButtons = Hide for that GridBoundColumn. You can also set style.ReadOnly = true for the column. > >Or, another option would be to set style.CellType = "Static" for the GridBoundColumn. > >GridStyleInfo style = this.grid.Binder.InternalColumns["TheDateCol"].StyleInfo; >style.CellType = "Static"; >style.CellValueType = typeof(DateTime); >style.Format = "MM/dd/yyyy"; > >This code assumes you have not explicitly added GridBoundColumns to teh grid. If you have, then use style = grid.GridBoundColumns["TheDateCol"].StyleInof to get the style object for the column.


JA James A Frisby(For EPS - Computer Software) July 27, 2004 03:55 PM UTC

Clay, After reading some other articles on your site, I tried g1.Binder.InternalColumns(i).StyleInfo.ReadOnly = True That seems to have worked Jim > >Clay, >I tried several of these options, I would like to set the whole grid (all the columns) to read only, as I''m editing and creating records on another form, however, when I try to access the "GridBoundColumn" collection, it''s empty. > >I haven''t explicitly added any columns, just bound a dataset to the grid. > >I also tried to iterate all the cells in the grid (with bound data) trying to set showbutton to "hide", and trying to set the cells to readonly. it doesn''t raise an error, but it doesn''t change the property either. > >Jim >>You can just hide the button by setting style.ShowButtons = Hide for that GridBoundColumn. You can also set style.ReadOnly = true for the column. >> >>Or, another option would be to set style.CellType = "Static" for the GridBoundColumn. >> >>GridStyleInfo style = this.grid.Binder.InternalColumns["TheDateCol"].StyleInfo; >>style.CellType = "Static"; >>style.CellValueType = typeof(DateTime); >>style.Format = "MM/dd/yyyy"; >> >>This code assumes you have not explicitly added GridBoundColumns to teh grid. If you have, then use style = grid.GridBoundColumns["TheDateCol"].StyleInof to get the style object for the column.


AD Administrator Syncfusion Team July 27, 2004 03:57 PM UTC

Here is a minimal sample with aReadOnly grid and a DateColumn not showing the buttons. ReadOnlyDates_4890.zip

Loader.
Live Chat Icon For mobile
Up arrow icon