PDA

Click to See Complete Forum and Search --> : DATAGRID?


ChrisM
Sep 16th, 1999, 02:33 PM
Does anyone know how to set the format of a DataGrid column, where the DataGrid is bound to an ado recordset at runtime?

JHausmann
Sep 19th, 1999, 04:56 AM
If it's anything like DAO, it's one of those things about bound controls that bother me.

With DAO, formatting (on the bound fields) is lost when the update method is issued. You need to re-format the bound fields after the ".update" occurs.

ChrisM
Sep 19th, 1999, 12:08 PM
The recordset is bound at run time (set datagrid.datasource = Rs). What I want to do is set the format of a particular column at run-time after the grid has been bound to the recordset.

VorTechS
Sep 20th, 1999, 12:31 PM
Well, if your refering to column sizes etc...

The syntax is something along the lines of:-

dbgrid1.colums(0).width = 3000
dbgrid1.columns(0).caption = "Hello"

By default I don't think VB shows these properties with the auto-complete.

ChrisM
Sep 20th, 1999, 01:28 PM
I was actually refering to the column format, i.e Boolean, Short Date etc.

JHausmann
Sep 20th, 1999, 09:38 PM
The answer, then, is most likely no. The data types of the columns are determined by the bindings. You might want to give some thought to having two grids, one bound, the other unbound that overlay one another.

ChrisM
Sep 21st, 1999, 12:09 PM
Unfortunately the recordsets I am dealing with are disconected and are bound at run-time. To bind a grid to a dataanvironment or data control would compomise the structure of the application.

Emon
Sep 29th, 1999, 08:18 PM
try right clicking on the control in design time and bring up the properties box. There is a list of formats under the column tab and in the Number Format drop down box you can choose the format you want to put into your code. Remember to use quotes.