473,694 Members | 2,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrids..... i just cant get them to do what i want

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 GridColumnStyle s
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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)

ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"

Dim ts As New DataGridTableSt yle()
ts.MappingName = "Table"

DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts)
Me.DataGrid1.Da taSource = ds.Tables(0)
ts.GridColumnSt yles(0).Width = 90
ts.GridColumnSt yles(1).Width = 90
ts.GridColumnSt yles(2).Width = 100
ts.GridColumnSt yles(3).Width = 90
ts.GridColumnSt yles(4).Width = 90
ts.GridColumnSt yles(5).Width = 90
ts.GridColumnSt yles(6).Width = 250
RowCount = ds.Tables(0).Ro ws.Count
ColumnCount = ds.Tables(0).Co lumns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose()
Nov 20 '05 #1
7 1426
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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"),
"MM/dd/yyyy")

hope this helps.......


"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:sm******** **********@news fep2-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 GridColumnStyle s
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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)

ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"

Dim ts As New DataGridTableSt yle()
ts.MappingName = "Table"

DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts)
Me.DataGrid1.Da taSource = ds.Tables(0)
ts.GridColumnSt yles(0).Width = 90
ts.GridColumnSt yles(1).Width = 90
ts.GridColumnSt yles(2).Width = 100
ts.GridColumnSt yles(3).Width = 90
ts.GridColumnSt yles(4).Width = 90
ts.GridColumnSt yles(5).Width = 90
ts.GridColumnSt yles(6).Width = 250
RowCount = ds.Tables(0).Ro ws.Count
ColumnCount = ds.Tables(0).Co lumns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose()

Nov 20 '05 #2
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 DataGridColumnS tyle objects and add them to the
GridColumnStyle sCollection before adding DataGridTableSt yle objects to the
GridTableStyles Collection. When you add an empty DataGridTableSt yle to the
collection, DataGridColumnS tyle objects are automatically generated for you.
Consequently, an exception will be thrown if you try to add new
DataGridColumnS tyle objects with duplicate MappingName values to the
GridColumnStyle sCollection.

d) Create DataGridColumnS tyle instances manually for each of the data
columns. The "DataGridTableS tyle 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.c o.uk.SPAM> wrote in message
news:sm******** **********@news fep2-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 GridColumnStyle s
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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)

ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"

Dim ts As New DataGridTableSt yle()
ts.MappingName = "Table"

DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts)
Me.DataGrid1.Da taSource = ds.Tables(0)
ts.GridColumnSt yles(0).Width = 90
ts.GridColumnSt yles(1).Width = 90
ts.GridColumnSt yles(2).Width = 100
ts.GridColumnSt yles(3).Width = 90
ts.GridColumnSt yles(4).Width = 90
ts.GridColumnSt yles(5).Width = 90
ts.GridColumnSt yles(6).Width = 250
RowCount = ds.Tables(0).Ro ws.Count
ColumnCount = ds.Tables(0).Co lumns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose()


Nov 20 '05 #3
)
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.It em(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.It em(0, 0) = Format(Me.DataG rid1.Item(0, 0), "MM/dd/yyyy
HH:mm:ss")
Dim mytime As String
mytime = Me.DataGrid1.It em(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 :-(


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:ux******** *****@tk2msftng p13.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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"),
"MM/dd/yyyy")

hope this helps.......


"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:sm******** **********@news fep2-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 GridColumnStyle s
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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)

ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"

Dim ts As New DataGridTableSt yle()
ts.MappingName = "Table"

DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts)
Me.DataGrid1.Da taSource = ds.Tables(0)
ts.GridColumnSt yles(0).Width = 90
ts.GridColumnSt yles(1).Width = 90
ts.GridColumnSt yles(2).Width = 100
ts.GridColumnSt yles(3).Width = 90
ts.GridColumnSt yles(4).Width = 90
ts.GridColumnSt yles(5).Width = 90
ts.GridColumnSt yles(6).Width = 250
RowCount = ds.Tables(0).Ro ws.Count
ColumnCount = ds.Tables(0).Co lumns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose()


Nov 20 '05 #4
Put a try catch block around the areas that are bombing and tell what it is
reporting....

"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:oL******** **********@news fep2-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.It em(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.It em(0, 0) = Format(Me.DataG rid1.Item(0, 0), "MM/dd/yyyy
HH:mm:ss")
Dim mytime As String
mytime = Me.DataGrid1.It em(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 :-(


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:ux******** *****@tk2msftng p13.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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"),
"MM/dd/yyyy")

hope this helps.......


"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:sm******** **********@news fep2-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 GridColumnStyle s
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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
'Fill the DataSet with the Data
da.Fill(ds)

ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"

Dim ts As New DataGridTableSt yle()
ts.MappingName = "Table"

DataGrid1.Table Styles.Clear()
DataGrid1.Table Styles.Add(ts)
Me.DataGrid1.Da taSource = ds.Tables(0)
ts.GridColumnSt yles(0).Width = 90
ts.GridColumnSt yles(1).Width = 90
ts.GridColumnSt yles(2).Width = 100
ts.GridColumnSt yles(3).Width = 90
ts.GridColumnSt yles(4).Width = 90
ts.GridColumnSt yles(5).Width = 90
ts.GridColumnSt yles(6).Width = 250
RowCount = ds.Tables(0).Ro ws.Count
ColumnCount = ds.Tables(0).Co lumns.Count
da.Dispose()
ds.Dispose()
ocon.Close()
ocon.Dispose()



Nov 20 '05 #5
sorry you misunderstood

the code that i initially posted has no problems

the problems come when i try to use the gridcolumnstyle s 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.ta blestyles(0).gr idcolumnstyles( "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."


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:#e******** ******@TK2MSFTN GP09.phx.gbl...
Put a try catch block around the areas that are bombing and tell what it is reporting....

"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:oL******** **********@news fep2-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.It em(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.It em(0, 0) = Format(Me.DataG rid1.Item(0, 0), "MM/dd/yyyy
HH:mm:ss")
Dim mytime As String
mytime = Me.DataGrid1.It em(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 :-(


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:ux******** *****@tk2msftng p13.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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"),
"MM/dd/yyyy")

hope this helps.......


"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message news:sm******** **********@news fep2-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 GridColumnStyle s
> 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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
> 'Fill the DataSet with the Data
> da.Fill(ds)
>
> ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
> ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
> ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
> ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
> ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
> ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
> ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"
>
> Dim ts As New DataGridTableSt yle()
> ts.MappingName = "Table"
>
> DataGrid1.Table Styles.Clear()
> DataGrid1.Table Styles.Add(ts)
> Me.DataGrid1.Da taSource = ds.Tables(0)
> ts.GridColumnSt yles(0).Width = 90
> ts.GridColumnSt yles(1).Width = 90
> ts.GridColumnSt yles(2).Width = 100
> ts.GridColumnSt yles(3).Width = 90
> ts.GridColumnSt yles(4).Width = 90
> ts.GridColumnSt yles(5).Width = 90
> ts.GridColumnSt yles(6).Width = 250
> RowCount = ds.Tables(0).Ro ws.Count
> ColumnCount = ds.Tables(0).Co lumns.Count
> da.Dispose()
> ds.Dispose()
> ocon.Close()
> ocon.Dispose()
>
>



Nov 20 '05 #6
Mike,
me.datagrid1.ta blestyles(0).gr idcolumnstyles( "MM/dd/yyyy HH:mm:ss")
should be changed to:

me.datagrid1.ta blestyles(0).gr idcolumnstyles( 0).Format = "MM/dd/yyyy
HH:mm:ss"
^^^
Where the second zero (the one in the parenthes following the
"gridcolumnstyl es") 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.c o.uk.SPAM> wrote in message
news:Xx******** **********@news fep2-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 gridcolumnstyle s 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.ta blestyles(0).gr idcolumnstyles( "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."


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:#e******** ******@TK2MSFTN GP09.phx.gbl...
Put a try catch block around the areas that are bombing and tell what it

is
reporting....

"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message
news:oL******** **********@news fep2-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.It em(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.It em(0, 0) = Format(Me.DataG rid1.Item(0, 0), "MM/dd/yyyy
HH:mm:ss")
Dim mytime As String
mytime = Me.DataGrid1.It em(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 :-(


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:ux******** *****@tk2msftng p13.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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"),
> "MM/dd/yyyy")
>
> hope this helps.......
>
>
>
>
> "Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in message > news:sm******** **********@news fep2-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 GridColumnStyle s
> > 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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
> > 'Fill the DataSet with the Data
> > da.Fill(ds)
> >
> > ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
> > ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
> > ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
> > ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
> > ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
> > ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
> > ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"
> >
> > Dim ts As New DataGridTableSt yle()
> > ts.MappingName = "Table"
> >
> > DataGrid1.Table Styles.Clear()
> > DataGrid1.Table Styles.Add(ts)
> > Me.DataGrid1.Da taSource = ds.Tables(0)
> > ts.GridColumnSt yles(0).Width = 90
> > ts.GridColumnSt yles(1).Width = 90
> > ts.GridColumnSt yles(2).Width = 100
> > ts.GridColumnSt yles(3).Width = 90
> > ts.GridColumnSt yles(4).Width = 90
> > ts.GridColumnSt yles(5).Width = 90
> > ts.GridColumnSt yles(6).Width = 250
> > RowCount = ds.Tables(0).Ro ws.Count
> > ColumnCount = ds.Tables(0).Co lumns.Count
> > da.Dispose()
> > ds.Dispose()
> > ocon.Close()
> > ocon.Dispose()
> >
> >
>
>




Nov 20 '05 #7
that doesnt work either

that just gives me the compile error:
format' is not a member of 'System.Windows .Forms.DataGrid ColumnStyle'.

cheers

Mike
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:eL******** ******@TK2MSFTN GP12.phx.gbl...
Mike,
me.datagrid1.ta blestyles(0).gr idcolumnstyles( "MM/dd/yyyy HH:mm:ss")


should be changed to:

me.datagrid1.ta blestyles(0).gr idcolumnstyles( 0).Format = "MM/dd/yyyy
HH:mm:ss"
^^^
Where the second zero (the one in the parenthes following the
"gridcolumnstyl es") 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.c o.uk.SPAM> wrote in message
news:Xx******** **********@news fep2-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 gridcolumnstyle s 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.ta blestyles(0).gr idcolumnstyles( "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."


"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:#e******** ******@TK2MSFTN GP09.phx.gbl...
Put a try catch block around the areas that are bombing and tell what it
is
reporting....

"Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in
message news:oL******** **********@news fep2-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.It em(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.It em(0, 0) = Format(Me.DataG rid1.Item(0, 0), "MM/dd/yyyy > HH:mm:ss")
> Dim mytime As String
> mytime = Me.DataGrid1.It em(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 :-(
>
>
>
>
>
>
> "scorpion53 061" <sc************ @yahoo.com> wrote in message
> news:ux******** *****@tk2msftng p13.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(Dsjobite ms1.Tables(0).R ows(0).Item("MY DATE"), > > "MM/dd/yyyy")
> >
> > hope this helps.......
> >
> >
> >
> >
> > "Mike Fellows" <mi************ *@equityhouse.c o.uk.SPAM> wrote in

message
> > news:sm******** **********@news fep2-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 GridColumnStyle s
> > > 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.SelectComman d = New OleDbCommand(SQ LStr, ocon)
> > > 'Fill the DataSet with the Data
> > > da.Fill(ds)
> > >
> > > ds.Tables(0).Co lumns.Item(0).C olumnName = "Date & Time"
> > > ds.Tables(0).Co lumns.Item(1).C olumnName = "Call Made By"
> > > ds.Tables(0).Co lumns.Item(2).C olumnName = "Days Since RTB"
> > > ds.Tables(0).Co lumns.Item(3).C olumnName = "Action"
> > > ds.Tables(0).Co lumns.Item(4).C olumnName = "Price In"
> > > ds.Tables(0).Co lumns.Item(5).C olumnName = "Property Valued"
> > > ds.Tables(0).Co lumns.Item(6).C olumnName = "Notes"
> > >
> > > Dim ts As New DataGridTableSt yle()
> > > ts.MappingName = "Table"
> > >
> > > DataGrid1.Table Styles.Clear()
> > > DataGrid1.Table Styles.Add(ts)
> > > Me.DataGrid1.Da taSource = ds.Tables(0)
> > > ts.GridColumnSt yles(0).Width = 90
> > > ts.GridColumnSt yles(1).Width = 90
> > > ts.GridColumnSt yles(2).Width = 100
> > > ts.GridColumnSt yles(3).Width = 90
> > > ts.GridColumnSt yles(4).Width = 90
> > > ts.GridColumnSt yles(5).Width = 90
> > > ts.GridColumnSt yles(6).Width = 250
> > > RowCount = ds.Tables(0).Ro ws.Count
> > > ColumnCount = ds.Tables(0).Co lumns.Count
> > > da.Dispose()
> > > ds.Dispose()
> > > ocon.Close()
> > > ocon.Dispose()
> > >
> > >
> >
> >
>
>


Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1675
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 error: Expected ';'
4
1922
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
1
2036
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... Me.dgTariffHolidayHomesBand1.DataSource = objCmd.ExecuteReader()
1
2330
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 is that on a postback I lose all the datagrids and their data. I have looked at numerous pages on the net regarding this issue. Many say you have to rebuild build the controls on postback. How am I meant to do this in my situation as I don't...
3
1972
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 about 20px. the amount of rows in those grids is changing, but the position of each datagrid seems to be fixed. this results in a grid overlaying another one or the space between two grids is way too high.
1
1525
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: Dim masterGrid As DataGrid Dim detailGrid As DataGrid
7
1845
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 in a different dataset. One combo box is displaying the Employees payroll ID. The other is
2
1932
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 particular order (like ProductID, Name, Description, Quantity etc.) are displayed in one DataGrid where as the personal details of the buyer corresponding to this order (like Name, E-Mail, Shipping & Billing Address etc.) are displayed in another...
1
1155
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 rows, selecting rows, handling events, etc. I know how to handle them in Asp.net, but not as sure when dealing with DataGrids in a Windows Form. Where would I find some good articles on these?
0
9107
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8816
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8812
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5825
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.