Datagrid TableStyles question...

J

johnb41

I'm attempting to display a datagrid with an EXTRA column: a checkbox
column. I successfully added it by creating a DataGridBoolColumn:

Dim ts1 As New DataGridTableStyle
ts1.MappingName = "Archive"
Dim colDiscontinued As New DataGridBoolColumn
With colDiscontinued
.MappingName = "abc"
.HeaderText = "xyz"
.Width = 80
End With
ts1.GridColumnStyles.Add(colDiscontinued)
DataGrid1.TableStyles.Add(ts1)

This works. BUT the resulting Datagrid ONLY shows this checkbox
column. I want this column to show up in addition to all the default
columns. Do I have to write code to show all the other columns, or is
there a simple way?

Also, I don't want to MAP this checkbox column with anything. I just
need checkboxes to show up next to each column for the user to click
on. Then i'll write code to determine what rows were selected and then
do something with them. If i leave the .Mappingname property blank,
the column just disappears. Any help/advice for this?

Thanks so much for all your help!
John
 
C

Cor Ligthert

John,

The answer on the first question is yes, you need to set for all columns
styles, if you use one.

The second questions. The name of the datagrid is "datagrid" and not grid,
because it uses underlaying data.

There is no simple Grid as control in the Windowsform part of Net. However
I don't see your problem, accessing a column in a datatable is very easy and
when you need an empty one, you just add an extra one to your table.

DataTable.Columns.add("myBool",Gettype(system.Boolean))

I hope this helps,

Cor
 
J

johnb41

Cor,

Thanks for the info. The problem for me is that datatable.columns.add
adds a column to the "end". I really need it before all the columns.

I'm assuming that if I do this, I can then create a tablestyle where I
create all the columns, and just put the checkbox column at the
beginning. I'll try this out!

Thanks!
John
 
C

Cor Ligthert

John,
Thanks for the info. The problem for me is that datatable.columns.add
adds a column to the "end". I really need it before all the columns.

I'm assuming that if I do this, I can then create a tablestyle where I
create all the columns, and just put the checkbox column at the
beginning. I'll try this out!
Therefore are the columnstyles they are used in your grid in the sequence as
you add them them to the styles. I really don't know how to make a decent
datagrid without the styles.

I hope this helps,

Cor
 
J

johnb41

Helps alot, thanks! I just find this very complicated because I have
more experience w/ asp.net datagrids, which I think make much more
sense to me. I wish both types of datagrids worked more similarly. Oh
well. Thanks again!

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top