Has anyone gotten this done? Specifically we don't want very much. We can
sort of see how to do it from the various resources that have been
referenced, but it seems like jumping through alot more hoops and coding
than should be necessary. We just want to change the "default" format for
how the datagrid handles dates from mm/dd/yy to include the time (mm/dd/yy
hh:mm). We use the same datagrid to load results from various mssql
datasets and it all works fine, except we want the long date/time format.
Since we load various datasets into the same grid we don't know ahead of
time how many columns there will be, what the columns are, or which ones are
dates. The datagrid seems to handle all this fine filling in the column
headers, number of columns --- everything just fine based on the dataset,
BUT somehow when it puts in a date in does mm/dd/yy.
"Vagabond Software" <carlfenley-X-@-X-san.rr.com> wrote in message
news:(E-Mail Removed)...
"Paps" <(E-Mail Removed)> wrote in message
news:8840D023-701E-4C47-B679-(E-Mail Removed)...
>
>
> "Vagabond Software" wrote:
>
> > "Paps" <(E-Mail Removed)> wrote in message
> > news:61E07967-B03A-440E-971A-(E-Mail Removed)...
> > > Hi all,
> > >
> > > I have populated my grid from a dataSet.
> > >
> > > 1) I want to enter certain values and in Caps in my second col. Like I
> > > want
> > > to enter only 'PAT' or 'SAT'. is this possible.
> > >
> > > 2) When my Grid populatyes the fourth col is not fully visible. I will
> > > have
> > > to increase the width each time when it displays. Is it possible to
> > > set the
> > > width of the 4th col only.
> > >
> > > 3) In my fifth col I want to enter date in this format only
> > > 'MM/DD/YYYY' and
> > > should not allow any charcaters in it but Date.
> >
> > You'll need to use TableStyles and DataGridColumnStyles. Here is an
> > example of a DataGrid that might display File Name, File Size, and Last
> > Modified date:
>
> I tried adding the code with what you gave but I get all kinds of error:
> Here is the code whic I put in my form Load event:
>
> I have stuck a Datagrid on my form its called Datagrid1
>
> DataGridTableStyle(style = New DataGridTableStyle())
> 'style.MappingName = DataSet.FileInfo.TableName
> style.AllowSorting = False
> style.AlternatingBackColor = Color.AliceBlue
> style.HeaderForeColor = Color.Blue
> style.DataGrid = this.dataGrid1
>
> I get the error @
> 'DataGridTableStyle(Style
> DatagridTableStyle is a Type only and cannot be used as an expression.
> Am I missing out something here.
I'm not that familiar Visual Basic.NET syntax, so double-check my syntax
against other similar syntax used for similar declarations. For example:
Dim style As New DataGridTableStyle()
Also, it looks like you have the MappingName property assignment commented
out. You'll need to map that to a TableName of an existing DataTable
contained in your DataGrid1.DataSource.
Finally, this may simply be a typo in your post, but you say that you have a
DataGrid control named "DataGrid1", but you assign the DataGrid property of
the TableStyle to "this.dataGrid1" (with a small 'd').
Here is an example of using DataGridTableStyles with Visual Basic.NET from
Microsoft:
http://msdn.microsoft.com/library/de...tylestopic.asp
I hope that helps.
- carl