add a boolcolumn to datagrid

U

uknees

Hi,

I want to have a datagrid filled with data for the users to select
which ever record they want and poplulate to another datagrid on
another form(which is the calling form)

Very much like letting the user clicking on the checkboxes on the
datagrid then click on the button to have the data transported to the
calling page's datagrid.

So... I was wondering how i can add a boolean column to a datagrid? I
know i can use the DataGridBoolColumn to add a DataGridColumnStyle.
but, what if this column i am adding is not in the dataset or
datatable?
 
K

Ken Tucker [MVP]

Hi,

You have to add a new column to the datatable.


Dim strConn As String

Dim conn As SqlConnection

Dim daCustomer As SqlDataAdapter

Dim ds As DataSet

ds = New DataSet()

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = Northwind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

daCustomer = New SqlDataAdapter("Select * from Customers", conn)

ds = New DataSet

daCustomer.Fill(ds, "Customers")

Dim dc As New DataColumn("MyBoolColumn", GetType(Boolean))

ds.Tables("Customers").Columns.Add(dc)

DataGrid1.DataSource = ds.Tables("Customers")



Ken
 
U

uknees

Hi Ken,

Can you also show me how the code will look like if I want to have a
boolean column added to the datagrid which is not from the dataset.
That is, the value of this column is not captured in the
dataset/database.
 

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

Similar Threads


Top