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.
Unfortunately, activation email could not send to your email. Please try again.

Date display in data bound grid

Thread ID:

Created:

Updated:

Platform:

Replies:

16884 Jul 26,2004 06:14 PM Jul 27,2004 11:57 AM Windows Forms 4
loading
Tags: GridControl
James A Frisby(For EPS - Computer Software)
Asked On July 26, 2004 06:14 PM

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

Administrator [Syncfusion]
Replied On July 26, 2004 06:23 PM

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.

James A Frisby(For EPS - Computer Software)
Replied On July 27, 2004 11:20 AM

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.

James A Frisby(For EPS - Computer Software)
Replied On July 27, 2004 11:55 AM

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.

Administrator [Syncfusion]
Replied On July 27, 2004 11:57 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;