add a boolcolumn to datagrid

  • Thread starter Thread starter uknees
  • Start date Start date
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?
 
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
 
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

Update Datagrid's table 4
Help creating columns for a datagrid! 4
Proper way to bind data from sqlserver to datagrid 1
Datatable clear 4
Datagrid update 3
Can be done? 1
Sorting a datagrid 1
Rows in Datagrid 12

Back
Top