Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

grid column in vb.net (pocket pc)

45 views
Skip to first unread message

Steiner Hubert

unread,
Mar 31, 2005, 7:15:57 AM3/31/05
to
hello,
i use this code:
toGrid.DataSource = dset.Tables("myTable")

this works fine - but here is my id field visible

-> how can i hide this id column in the grid?


Sergey Bogdanov

unread,
Mar 31, 2005, 7:26:07 AM3/31/05
to

Michel Renaud

unread,
Mar 31, 2005, 7:27:03 AM3/31/05
to
Use a DataGridTableStyle (see VS.Net help for more info + examples) and set
the width of the column to 0. That'll also allow you to set the width of
other columns, if need be.

Steiner Hubert

unread,
Mar 31, 2005, 10:03:38 AM3/31/05
to
hello,
the code:
Dim dadp As New SqlServerCe.SqlCeDataAdapter("SELECT * FROM Mittel", cn)
Dim dset As New DataSet
dadp.Fill(dset, "Mittel")

Dim dgts As New DataGridTableStyle
dgts.MappingName = "Mittel"
Dim c As New DataGridTextBoxColumn
c.MappingName = "Name"
c.HeaderText = "Mittel"
c.Width = 100
dgts.GridColumnStyles.Add(c)
toGrid.TableStyles.Add(dgts)

-> but in the grid no column is visible
please help


Sergey Bogdanov

unread,
Mar 31, 2005, 10:09:16 AM3/31/05
to
Did you set the DataSource with "dset" for DataGrid?

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Steiner Hubert

unread,
Mar 31, 2005, 1:41:06 PM3/31/05
to
thank you!

my ID field is in the grid not visible
the user click now in a row

-> how can i determine the id field
at the active row of the grid?


Sergey Bogdanov

unread,
Mar 31, 2005, 2:18:33 PM3/31/05
to
Try this:

dataTable.DefaultView(dataGrid.CurrentRowIndex)("id")

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Steiner Hubert

unread,
Mar 31, 2005, 4:56:26 PM3/31/05
to
sorry, i am a beginner

Dim dadp As New SqlServerCe.SqlCeDataAdapter("SELECT * FROM Mittel", cn)
Dim dset As New DataSet
dadp.Fill(dset, "Mittel")
Dim dgts As New DataGridTableStyle
dgts.MappingName = "Mittel"
Dim c As New DataGridTextBoxColumn
c.MappingName = "Name"
c.HeaderText = "Mittel"
c.Width = 100
dgts.GridColumnStyles.Add(c)
toGrid.TableStyles.Add(dgts)

toGrid.DataSource = dset.Tables("Mittel")

rem ???
dset.Tables("Mittel").DefaultView(toGrid.CurrentRowIndex)("id")
rem ???


Sergey Bogdanov

unread,
Mar 31, 2005, 11:26:40 PM3/31/05
to
Create button and implement Click handler for this button. Inside this
handler input the following code snippet that shows current selected
record ID:


MessageBox.Show(dset.Tables("Mittel").DefaultView(toGrid.CurrentRowIndex)("id").ToString())

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Steiner Hubert

unread,
Apr 1, 2005, 3:18:47 AM4/1/05
to
THANK YOU!


0 new messages