Below is my code that is carried out on my dataset, datagrid etc...
Im trying to get column0 "Date & Time" to show date and time, not just date
ive read some stuff posted by Dmitriy Lapshin on this board that goes way
over my
ability (this is my first vb or vb.net project). from what I can tell i
need a GridColumnStyles
collection adding to my datagrid but each and everytime I try to do this my
code crashes.
It seems such a simple problem that is taking way too long to try and sort,
so any help would be greatly appreciated
Regards
Mike Fellows
da.SelectCommand = New OleDbCommand(SQLStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)
ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time"
ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By"
ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB"
ds.Tables(0).Columns.Item(3).ColumnName = "Action"
ds.Tables(0).Columns.Item(4).ColumnName = "Price In"
ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued"
ds.Tables(0).Columns.Item(6).ColumnName = "Notes"
Dim ts As New DataGridTableStyle()
ts.MappingName = "Table"
DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(ts)
Me.DataGrid1.DataSource = ds.Tables(0)
ts.GridColumnStyles(0).Width = 90
ts.GridColumnStyles(1).Width = 90
ts.GridColumnStyles(2).Width = 100
ts.GridColumnStyles(3).Width = 90
ts.GridColumnStyles(4).Width = 90
ts.GridColumnStyles(5).Width = 90
ts.GridColumnStyles(6).Width = 250
RowCount = ds.Tables(0).Rows.Count
ColumnCount = ds.Tables(0).Columns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose() 7 1413
First of all never say your code "crashes". It says nothing about the
problem. Always use a Try Catch block to trap the error and report that.
Dates and times throw many beginners for a loop.
i suspect the problem is with your database setup. See the ADO.NET ng about
that. If you are using an access database the simple Date/Time field will do
what you want. The "General" under format will work nicely.
But lets say you were filling a textbox with a date/time setup and it was
not the way you wanted it:
TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss")
or
Textbox7.Text = Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ),
"MM/dd/yyyy")
hope this helps.......
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:sm******************@newsfep2-gui.server.ntli.net... Below is my code that is carried out on my dataset, datagrid etc...
Im trying to get column0 "Date & Time" to show date and time, not just
date ive read some stuff posted by Dmitriy Lapshin on this board that goes way over my ability (this is my first vb or vb.net project). from what I can tell i need a GridColumnStyles collection adding to my datagrid but each and everytime I try to do this
my code crashes.
It seems such a simple problem that is taking way too long to try and
sort, so any help would be greatly appreciated
Regards
Mike Fellows
da.SelectCommand = New OleDbCommand(SQLStr, ocon) 'Fill the DataSet with the Data da.Fill(ds)
ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" ds.Tables(0).Columns.Item(3).ColumnName = "Action" ds.Tables(0).Columns.Item(4).ColumnName = "Price In" ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" ds.Tables(0).Columns.Item(6).ColumnName = "Notes"
Dim ts As New DataGridTableStyle() ts.MappingName = "Table"
DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) Me.DataGrid1.DataSource = ds.Tables(0) ts.GridColumnStyles(0).Width = 90 ts.GridColumnStyles(1).Width = 90 ts.GridColumnStyles(2).Width = 100 ts.GridColumnStyles(3).Width = 90 ts.GridColumnStyles(4).Width = 90 ts.GridColumnStyles(5).Width = 90 ts.GridColumnStyles(6).Width = 250 RowCount = ds.Tables(0).Rows.Count ColumnCount = ds.Tables(0).Columns.Count da.Dispose() ds.Dispose() ocon.Close() ocon.Dispose()
Hi Mike,
Some observations on your code:
a) Never assign grid's DataSource property directly. Use the
SetDataBinding() method instead.
b) The table style/column style setup should always be done BEFORE the data
source is bound to the grid.
c) Mind this caution from MSDN Library:
CAUTION Always create DataGridColumnStyle objects and add them to the
GridColumnStylesCollection before adding DataGridTableStyle objects to the
GridTableStylesCollection. When you add an empty DataGridTableStyle to the
collection, DataGridColumnStyle objects are automatically generated for you.
Consequently, an exception will be thrown if you try to add new
DataGridColumnStyle objects with duplicate MappingName values to the
GridColumnStylesCollection.
d) Create DataGridColumnStyle instances manually for each of the data
columns. The "DataGridTableStyle Class" topic in the MSDN library gives a
good example on how to do that.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:sm******************@newsfep2-gui.server.ntli.net... Below is my code that is carried out on my dataset, datagrid etc...
Im trying to get column0 "Date & Time" to show date and time, not just
date ive read some stuff posted by Dmitriy Lapshin on this board that goes way over my ability (this is my first vb or vb.net project). from what I can tell i need a GridColumnStyles collection adding to my datagrid but each and everytime I try to do this
my code crashes.
It seems such a simple problem that is taking way too long to try and
sort, so any help would be greatly appreciated
Regards
Mike Fellows
da.SelectCommand = New OleDbCommand(SQLStr, ocon) 'Fill the DataSet with the Data da.Fill(ds)
ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" ds.Tables(0).Columns.Item(3).ColumnName = "Action" ds.Tables(0).Columns.Item(4).ColumnName = "Price In" ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" ds.Tables(0).Columns.Item(6).ColumnName = "Notes"
Dim ts As New DataGridTableStyle() ts.MappingName = "Table"
DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) Me.DataGrid1.DataSource = ds.Tables(0) ts.GridColumnStyles(0).Width = 90 ts.GridColumnStyles(1).Width = 90 ts.GridColumnStyles(2).Width = 100 ts.GridColumnStyles(3).Width = 90 ts.GridColumnStyles(4).Width = 90 ts.GridColumnStyles(5).Width = 90 ts.GridColumnStyles(6).Width = 250 RowCount = ds.Tables(0).Rows.Count ColumnCount = ds.Tables(0).Columns.Count da.Dispose() ds.Dispose() ocon.Close() ocon.Dispose()
)
NNTP-Posting-Date: Mon, 20 Oct 2003 13:43:00
Organization: ntl Cablemodem News Service
ok ive tried 2 things
Dim mytime As String
mytime = Me.DataGrid1.Item(0, 0)
MessageBox.Show(mytime)
this showed me that the datagrid was storing the time correclty just not
displaying it
then i tried
Me.DataGrid1.Item(0, 0) = Format(Me.DataGrid1.Item(0, 0), "MM/dd/yyyy
HH:mm:ss")
Dim mytime As String
mytime = Me.DataGrid1.Item(0, 0)
MessageBox.Show(mytime)
im not sure i did the above correctly but it didnt make any difference to
the diaply of the datagrid
and the messagebox still showed the time
so im back to square one :-(
"scorpion53061" <sc************@yahoo.com> wrote in message
news:ux*************@tk2msftngp13.phx.gbl... First of all never say your code "crashes". It says nothing about the problem. Always use a Try Catch block to trap the error and report that.
Dates and times throw many beginners for a loop.
i suspect the problem is with your database setup. See the ADO.NET ng
about that. If you are using an access database the simple Date/Time field will
do what you want. The "General" under format will work nicely.
But lets say you were filling a textbox with a date/time setup and it was not the way you wanted it:
TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss")
or
Textbox7.Text = Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ), "MM/dd/yyyy")
hope this helps.......
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message news:sm******************@newsfep2-gui.server.ntli.net... Below is my code that is carried out on my dataset, datagrid etc...
Im trying to get column0 "Date & Time" to show date and time, not just date ive read some stuff posted by Dmitriy Lapshin on this board that goes
way over my ability (this is my first vb or vb.net project). from what I can tell i need a GridColumnStyles collection adding to my datagrid but each and everytime I try to do this
my code crashes.
It seems such a simple problem that is taking way too long to try and sort, so any help would be greatly appreciated
Regards
Mike Fellows
da.SelectCommand = New OleDbCommand(SQLStr, ocon) 'Fill the DataSet with the Data da.Fill(ds)
ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" ds.Tables(0).Columns.Item(3).ColumnName = "Action" ds.Tables(0).Columns.Item(4).ColumnName = "Price In" ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" ds.Tables(0).Columns.Item(6).ColumnName = "Notes"
Dim ts As New DataGridTableStyle() ts.MappingName = "Table"
DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) Me.DataGrid1.DataSource = ds.Tables(0) ts.GridColumnStyles(0).Width = 90 ts.GridColumnStyles(1).Width = 90 ts.GridColumnStyles(2).Width = 100 ts.GridColumnStyles(3).Width = 90 ts.GridColumnStyles(4).Width = 90 ts.GridColumnStyles(5).Width = 90 ts.GridColumnStyles(6).Width = 250 RowCount = ds.Tables(0).Rows.Count ColumnCount = ds.Tables(0).Columns.Count da.Dispose() ds.Dispose() ocon.Close() ocon.Dispose()
Put a try catch block around the areas that are bombing and tell what it is
reporting....
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:oL******************@newsfep2-gui.server.ntli.net... ) NNTP-Posting-Date: Mon, 20 Oct 2003 13:43:00
Organization: ntl Cablemodem News Service
ok ive tried 2 things
Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
this showed me that the datagrid was storing the time correclty just not displaying it
then i tried
Me.DataGrid1.Item(0, 0) = Format(Me.DataGrid1.Item(0, 0), "MM/dd/yyyy HH:mm:ss") Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
im not sure i did the above correctly but it didnt make any difference to the diaply of the datagrid and the messagebox still showed the time
so im back to square one :-( "scorpion53061" <sc************@yahoo.com> wrote in message news:ux*************@tk2msftngp13.phx.gbl... First of all never say your code "crashes". It says nothing about the problem. Always use a Try Catch block to trap the error and report that.
Dates and times throw many beginners for a loop.
i suspect the problem is with your database setup. See the ADO.NET ng about that. If you are using an access database the simple Date/Time field
will do what you want. The "General" under format will work nicely.
But lets say you were filling a textbox with a date/time setup and it
was not the way you wanted it:
TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss")
or
Textbox7.Text = Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ), "MM/dd/yyyy")
hope this helps.......
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message news:sm******************@newsfep2-gui.server.ntli.net... Below is my code that is carried out on my dataset, datagrid etc...
Im trying to get column0 "Date & Time" to show date and time, not just date ive read some stuff posted by Dmitriy Lapshin on this board that goes way over my ability (this is my first vb or vb.net project). from what I can tell
i need a GridColumnStyles collection adding to my datagrid but each and everytime I try to do
this my code crashes.
It seems such a simple problem that is taking way too long to try and sort, so any help would be greatly appreciated
Regards
Mike Fellows
da.SelectCommand = New OleDbCommand(SQLStr, ocon) 'Fill the DataSet with the Data da.Fill(ds)
ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" ds.Tables(0).Columns.Item(3).ColumnName = "Action" ds.Tables(0).Columns.Item(4).ColumnName = "Price In" ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" ds.Tables(0).Columns.Item(6).ColumnName = "Notes"
Dim ts As New DataGridTableStyle() ts.MappingName = "Table"
DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) Me.DataGrid1.DataSource = ds.Tables(0) ts.GridColumnStyles(0).Width = 90 ts.GridColumnStyles(1).Width = 90 ts.GridColumnStyles(2).Width = 100 ts.GridColumnStyles(3).Width = 90 ts.GridColumnStyles(4).Width = 90 ts.GridColumnStyles(5).Width = 90 ts.GridColumnStyles(6).Width = 250 RowCount = ds.Tables(0).Rows.Count ColumnCount = ds.Tables(0).Columns.Count da.Dispose() ds.Dispose() ocon.Close() ocon.Dispose()
sorry you misunderstood
the code that i initially posted has no problems
the problems come when i try to use the gridcolumnstyles which is where i
think
i need to format the data in the datagrid
im sure i need to do somthing like the following:
me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss")
but i dont know how to get the datagrid to accept the above (if that makes
sense)
as i recieve the following error "Property access must assign to the
property or use its value."
"scorpion53061" <sc************@yahoo.com> wrote in message
news:#e**************@TK2MSFTNGP09.phx.gbl... Put a try catch block around the areas that are bombing and tell what it
is reporting....
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message news:oL******************@newsfep2-gui.server.ntli.net... ) NNTP-Posting-Date: Mon, 20 Oct 2003 13:43:00
Organization: ntl Cablemodem News Service
ok ive tried 2 things
Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
this showed me that the datagrid was storing the time correclty just not displaying it
then i tried
Me.DataGrid1.Item(0, 0) = Format(Me.DataGrid1.Item(0, 0), "MM/dd/yyyy HH:mm:ss") Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
im not sure i did the above correctly but it didnt make any difference
to the diaply of the datagrid and the messagebox still showed the time
so im back to square one :-( "scorpion53061" <sc************@yahoo.com> wrote in message news:ux*************@tk2msftngp13.phx.gbl... First of all never say your code "crashes". It says nothing about the problem. Always use a Try Catch block to trap the error and report
that. Dates and times throw many beginners for a loop.
i suspect the problem is with your database setup. See the ADO.NET ng about that. If you are using an access database the simple Date/Time field will do what you want. The "General" under format will work nicely.
But lets say you were filling a textbox with a date/time setup and it was not the way you wanted it:
TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss")
or
Textbox7.Text = Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ), "MM/dd/yyyy")
hope this helps.......
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in
message news:sm******************@newsfep2-gui.server.ntli.net... > Below is my code that is carried out on my dataset, datagrid etc... > > Im trying to get column0 "Date & Time" to show date and time, not
just date > > ive read some stuff posted by Dmitriy Lapshin on this board that
goes way > over my > ability (this is my first vb or vb.net project). from what I can
tell i > need a GridColumnStyles > collection adding to my datagrid but each and everytime I try to do this my > code crashes. > > It seems such a simple problem that is taking way too long to try
and sort, > so any help would be greatly appreciated > > Regards > > > Mike Fellows > > da.SelectCommand = New OleDbCommand(SQLStr, ocon) > 'Fill the DataSet with the Data > da.Fill(ds) > > ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" > ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" > ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" > ds.Tables(0).Columns.Item(3).ColumnName = "Action" > ds.Tables(0).Columns.Item(4).ColumnName = "Price In" > ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" > ds.Tables(0).Columns.Item(6).ColumnName = "Notes" > > Dim ts As New DataGridTableStyle() > ts.MappingName = "Table" > > DataGrid1.TableStyles.Clear() > DataGrid1.TableStyles.Add(ts) > Me.DataGrid1.DataSource = ds.Tables(0) > ts.GridColumnStyles(0).Width = 90 > ts.GridColumnStyles(1).Width = 90 > ts.GridColumnStyles(2).Width = 100 > ts.GridColumnStyles(3).Width = 90 > ts.GridColumnStyles(4).Width = 90 > ts.GridColumnStyles(5).Width = 90 > ts.GridColumnStyles(6).Width = 250 > RowCount = ds.Tables(0).Rows.Count > ColumnCount = ds.Tables(0).Columns.Count > da.Dispose() > ds.Dispose() > ocon.Close() > ocon.Dispose() > >
Mike, me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss")
should be changed to:
me.datagrid1.tablestyles(0).gridcolumnstyles(0).Fo rmat = "MM/dd/yyyy
HH:mm:ss"
^^^
Where the second zero (the one in the parenthes following the
"gridcolumnstyles") should be replaced with the index of the column style
corresponding to the datetime column.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:Xx******************@newsfep2-gui.server.ntli.net... sorry you misunderstood
the code that i initially posted has no problems
the problems come when i try to use the gridcolumnstyles which is where i think i need to format the data in the datagrid
im sure i need to do somthing like the following:
me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss")
but i dont know how to get the datagrid to accept the above (if that makes sense) as i recieve the following error "Property access must assign to the property or use its value."
"scorpion53061" <sc************@yahoo.com> wrote in message news:#e**************@TK2MSFTNGP09.phx.gbl... Put a try catch block around the areas that are bombing and tell what it is reporting....
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message news:oL******************@newsfep2-gui.server.ntli.net... ) NNTP-Posting-Date: Mon, 20 Oct 2003 13:43:00
Organization: ntl Cablemodem News Service
ok ive tried 2 things
Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
this showed me that the datagrid was storing the time correclty just
not displaying it
then i tried
Me.DataGrid1.Item(0, 0) = Format(Me.DataGrid1.Item(0, 0), "MM/dd/yyyy HH:mm:ss") Dim mytime As String mytime = Me.DataGrid1.Item(0, 0) MessageBox.Show(mytime)
im not sure i did the above correctly but it didnt make any difference to the diaply of the datagrid and the messagebox still showed the time
so im back to square one :-( "scorpion53061" <sc************@yahoo.com> wrote in message news:ux*************@tk2msftngp13.phx.gbl... > First of all never say your code "crashes". It says nothing about
the > problem. Always use a Try Catch block to trap the error and report that. > > Dates and times throw many beginners for a loop. > > i suspect the problem is with your database setup. See the ADO.NET
ng about > that. If you are using an access database the simple Date/Time field will do > what you want. The "General" under format will work nicely. > > But lets say you were filling a textbox with a date/time setup and
it was > not the way you wanted it: > > TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss") > > or > > Textbox7.Text = Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ), > "MM/dd/yyyy") > > hope this helps....... > > > > > "Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message > news:sm******************@newsfep2-gui.server.ntli.net... > > Below is my code that is carried out on my dataset, datagrid
etc... > > > > Im trying to get column0 "Date & Time" to show date and time, not just > date > > > > ive read some stuff posted by Dmitriy Lapshin on this board that goes way > > over my > > ability (this is my first vb or vb.net project). from what I can tell i > > need a GridColumnStyles > > collection adding to my datagrid but each and everytime I try to
do this > my > > code crashes. > > > > It seems such a simple problem that is taking way too long to try
and > sort, > > so any help would be greatly appreciated > > > > Regards > > > > > > Mike Fellows > > > > da.SelectCommand = New OleDbCommand(SQLStr, ocon) > > 'Fill the DataSet with the Data > > da.Fill(ds) > > > > ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" > > ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" > > ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" > > ds.Tables(0).Columns.Item(3).ColumnName = "Action" > > ds.Tables(0).Columns.Item(4).ColumnName = "Price In" > > ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" > > ds.Tables(0).Columns.Item(6).ColumnName = "Notes" > > > > Dim ts As New DataGridTableStyle() > > ts.MappingName = "Table" > > > > DataGrid1.TableStyles.Clear() > > DataGrid1.TableStyles.Add(ts) > > Me.DataGrid1.DataSource = ds.Tables(0) > > ts.GridColumnStyles(0).Width = 90 > > ts.GridColumnStyles(1).Width = 90 > > ts.GridColumnStyles(2).Width = 100 > > ts.GridColumnStyles(3).Width = 90 > > ts.GridColumnStyles(4).Width = 90 > > ts.GridColumnStyles(5).Width = 90 > > ts.GridColumnStyles(6).Width = 250 > > RowCount = ds.Tables(0).Rows.Count > > ColumnCount = ds.Tables(0).Columns.Count > > da.Dispose() > > ds.Dispose() > > ocon.Close() > > ocon.Dispose() > > > > > >
that doesnt work either
that just gives me the compile error:
format' is not a member of 'System.Windows.Forms.DataGridColumnStyle'.
cheers
Mike
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eL**************@TK2MSFTNGP12.phx.gbl... Mike,
me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss")
should be changed to:
me.datagrid1.tablestyles(0).gridcolumnstyles(0).Fo rmat = "MM/dd/yyyy HH:mm:ss" ^^^ Where the second zero (the one in the parenthes following the "gridcolumnstyles") should be replaced with the index of the column style corresponding to the datetime column.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message news:Xx******************@newsfep2-gui.server.ntli.net... sorry you misunderstood
the code that i initially posted has no problems
the problems come when i try to use the gridcolumnstyles which is where
i think i need to format the data in the datagrid
im sure i need to do somthing like the following:
me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss")
but i dont know how to get the datagrid to accept the above (if that
makes sense) as i recieve the following error "Property access must assign to the property or use its value."
"scorpion53061" <sc************@yahoo.com> wrote in message news:#e**************@TK2MSFTNGP09.phx.gbl... Put a try catch block around the areas that are bombing and tell what
it is reporting....
"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in
message news:oL******************@newsfep2-gui.server.ntli.net... > ) > NNTP-Posting-Date: Mon, 20 Oct 2003 13:43:00 > > > Organization: ntl Cablemodem News Service > > ok ive tried 2 things > > Dim mytime As String > mytime = Me.DataGrid1.Item(0, 0) > MessageBox.Show(mytime) > > this showed me that the datagrid was storing the time correclty just
not > displaying it > > then i tried > > Me.DataGrid1.Item(0, 0) = Format(Me.DataGrid1.Item(0, 0),
"MM/dd/yyyy > HH:mm:ss") > Dim mytime As String > mytime = Me.DataGrid1.Item(0, 0) > MessageBox.Show(mytime) > > > im not sure i did the above correctly but it didnt make any
difference to > the diaply of the datagrid > and the messagebox still showed the time > > so im back to square one :-( > > > > > > > "scorpion53061" <sc************@yahoo.com> wrote in message > news:ux*************@tk2msftngp13.phx.gbl... > > First of all never say your code "crashes". It says nothing about the > > problem. Always use a Try Catch block to trap the error and report that. > > > > Dates and times throw many beginners for a loop. > > > > i suspect the problem is with your database setup. See the ADO.NET ng > about > > that. If you are using an access database the simple Date/Time
field will > do > > what you want. The "General" under format will work nicely. > > > > But lets say you were filling a textbox with a date/time setup and it was > > not the way you wanted it: > > > > TextBox7.Text = Format(Date.Now, "MM/dd/yyyy HH:mm:ss") > > > > or > > > > Textbox7.Text =
Format(Dsjobitems1.Tables(0).Rows(0).Item("MYDATE" ), > > "MM/dd/yyyy") > > > > hope this helps....... > > > > > > > > > > "Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message > > news:sm******************@newsfep2-gui.server.ntli.net... > > > Below is my code that is carried out on my dataset, datagrid etc... > > > > > > Im trying to get column0 "Date & Time" to show date and time,
not just > > date > > > > > > ive read some stuff posted by Dmitriy Lapshin on this board that goes > way > > > over my > > > ability (this is my first vb or vb.net project). from what I
can tell i > > > need a GridColumnStyles > > > collection adding to my datagrid but each and everytime I try to do this > > my > > > code crashes. > > > > > > It seems such a simple problem that is taking way too long to
try and > > sort, > > > so any help would be greatly appreciated > > > > > > Regards > > > > > > > > > Mike Fellows > > > > > > da.SelectCommand = New OleDbCommand(SQLStr, ocon) > > > 'Fill the DataSet with the Data > > > da.Fill(ds) > > > > > > ds.Tables(0).Columns.Item(0).ColumnName = "Date & Time" > > > ds.Tables(0).Columns.Item(1).ColumnName = "Call Made By" > > > ds.Tables(0).Columns.Item(2).ColumnName = "Days Since RTB" > > > ds.Tables(0).Columns.Item(3).ColumnName = "Action" > > > ds.Tables(0).Columns.Item(4).ColumnName = "Price In" > > > ds.Tables(0).Columns.Item(5).ColumnName = "Property Valued" > > > ds.Tables(0).Columns.Item(6).ColumnName = "Notes" > > > > > > Dim ts As New DataGridTableStyle() > > > ts.MappingName = "Table" > > > > > > DataGrid1.TableStyles.Clear() > > > DataGrid1.TableStyles.Add(ts) > > > Me.DataGrid1.DataSource = ds.Tables(0) > > > ts.GridColumnStyles(0).Width = 90 > > > ts.GridColumnStyles(1).Width = 90 > > > ts.GridColumnStyles(2).Width = 100 > > > ts.GridColumnStyles(3).Width = 90 > > > ts.GridColumnStyles(4).Width = 90 > > > ts.GridColumnStyles(5).Width = 90 > > > ts.GridColumnStyles(6).Width = 250 > > > RowCount = ds.Tables(0).Rows.Count > > > ColumnCount = ds.Tables(0).Columns.Count > > > da.Dispose() > > > ds.Dispose() > > > ocon.Close() > > > ocon.Dispose() > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrzej Wegrzyn |
last post by:
Hi,
I had a portal that worked before, and over 5 months period JavaScript
errors started to show up on all forms where I have datagrids.
Using: IE 6.0, WIN XP, IIS 5.1, Framework 1.1
...
|
by: mark |
last post by:
i have datagrids set out as such on a webform with vb behind
datagrid1
datagrid2
datagrid3
datagrid4
datagrid5
datagrid6
datagrid7
|
by: Simon Harris |
last post by:
Hi All,
I wish to populate more than one datagrid from the same OleDBCommand. The
code I have is:
Dim objCmd As New OleDbCommand(strSql, objConn)
Then...
...
|
by: ree32 |
last post by:
I have a placeholder and depending on a user input(a drop downlist)
when the user clicks a button I dynamically create a number of
datagrids and fill them with data from a database. But the problem...
|
by: Mark Wiewel |
last post by:
hi all,
i am a newbie in ASP.NET and i couldn't find the solution to this one:
i have a form with three datagrids on it. i would like to align them
vertically with a space between each grid of...
|
by: Gary200 |
last post by:
Hello All,
I bind two datagrids in a master-detail relationship successfully.
What I want is to set allowNew and allowDelete disabled in both datagrid
using dataview.
The code like this:
...
|
by: Ausclad |
last post by:
Ok, ill try again.....
It seems fairly simple.
I have two combo boxes in a datagrid. The datagrid is bound to a a table in
a dataset.
The two combo boxes are bound to a single data table...
|
by: rn5a |
last post by:
In a shopping cart app, a ASPX page retrieves the order details &
personal details of a user from a MS-Access database table depending
upon the username of the user.
The order details of a...
|
by: tshad |
last post by:
I am trying to find the differences between handling of DataGrids in Windows
Forms and Asp.Net.
They are completely different in how you bind to them, get number of rows,
look at columns and...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |