| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
scorpion53061
Guest
Posts: n/a
|
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" <(E-Mail Removed)> wrote in message news:smOkb.314$(E-Mail Removed)... > 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() > > |
|
||
|
||||
|
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
|
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" <(E-Mail Removed)> wrote in message news:smOkb.314$(E-Mail Removed)... > 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 Fellows
Guest
Posts: n/a
|
)
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > 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" <(E-Mail Removed)> wrote in message > news:smOkb.314$(E-Mail Removed)... > > 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() > > > > > > |
|
||
|
||||
|
scorpion53061
Guest
Posts: n/a
|
Put a try catch block around the areas that are bombing and tell what it is
reporting.... "Mike Fellows" <(E-Mail Removed)> wrote in message news LQkb.592$(E-Mail Removed)...> ) > 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" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... > > 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" <(E-Mail Removed)> wrote in message > > news:smOkb.314$(E-Mail Removed)... > > > 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 Fellows
Guest
Posts: n/a
|
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)... > Put a try catch block around the areas that are bombing and tell what it is > reporting.... > > "Mike Fellows" <(E-Mail Removed)> wrote in message > news LQkb.592$(E-Mail Removed)...> > ) > > 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" <(E-Mail Removed)> wrote in message > > news:(E-Mail Removed)... > > > 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" <(E-Mail Removed)> wrote in message > > > news:smOkb.314$(E-Mail Removed)... > > > > 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() > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
|
Mike,
> me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss") should be changed to: me.datagrid1.tablestyles(0).gridcolumnstyles(0).Format = "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" <(E-Mail Removed)> wrote in message news:XxRkb.738$(E-Mail Removed)... > 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" <(E-Mail Removed)> wrote in message > news:#(E-Mail Removed)... > > Put a try catch block around the areas that are bombing and tell what it > is > > reporting.... > > > > "Mike Fellows" <(E-Mail Removed)> wrote in message > > news LQkb.592$(E-Mail Removed)...> > > ) > > > 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" <(E-Mail Removed)> wrote in message > > > news:(E-Mail Removed)... > > > > 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" <(E-Mail Removed)> wrote in > message > > > > news:smOkb.314$(E-Mail Removed)... > > > > > 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 Fellows
Guest
Posts: n/a
|
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-(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > Mike, > > > me.datagrid1.tablestyles(0).gridcolumnstyles("MM/dd/yyyy HH:mm:ss") > > should be changed to: > > me.datagrid1.tablestyles(0).gridcolumnstyles(0).Format = "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" <(E-Mail Removed)> wrote in message > news:XxRkb.738$(E-Mail Removed)... > > 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" <(E-Mail Removed)> wrote in message > > news:#(E-Mail Removed)... > > > Put a try catch block around the areas that are bombing and tell what it > > is > > > reporting.... > > > > > > "Mike Fellows" <(E-Mail Removed)> wrote in message > > > news LQkb.592$(E-Mail Removed)...> > > > ) > > > > 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" <(E-Mail Removed)> wrote in message > > > > news:(E-Mail Removed)... > > > > > 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" <(E-Mail Removed)> wrote in > > message > > > > > news:smOkb.314$(E-Mail Removed)... > > > > > > 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() > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Datagrids | Uncle X | Microsoft C# .NET | 0 | 8th Feb 2006 03:51 PM |
| Datagrids??? | Darryn Ross | Microsoft C# .NET | 1 | 19th Aug 2004 10:55 AM |
| Datagrids??? | Darryn Ross | Microsoft C# .NET | 1 | 9th Aug 2004 06:25 AM |
| Using Datagrids in vb.net | Ryan McConnell | Microsoft VB .NET | 4 | 13th Feb 2004 01:10 PM |
| Re: dataGrids | Majid Qazi | Microsoft VB .NET | 0 | 7th Sep 2003 07:44 PM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




