Adding data to DataGrid

G

Guest

I have got a prototype .Net2 WinForms that are binded to an Access DB Table
with some columns which have "default values".

I have allowed DataGrid to add data.

However, how could I get the "default values" in 2 columns to show up in new
row?
 
G

Guest

In addition, how could I control values that are allowed in another cell
value with a drop-down control?
 
C

Cor Ligthert [MVP]

Patrick,

Always try to access a DataGrid using the underlying dattable.

Cor
 
G

Guest

The DataGrid is already binded to the underlying DataTable.

But how do I code the grid so that
1) when a new row is inserted, I have default values pre-populated in 2
columns?
2) I have drop-down in 1 column to control values to be entered into the grid?
 
C

Cor Ligthert[MVP]

Patrick,

You know that you can set the default behaviour as well in the datatable. It
is a pity that this is not synchronized with by instance SQL server. You
have to set this in your program.

Cor
 
G

Guest

Can someone explain how I can code the .Net 2 DataGrid such that when a new
row is added, I can have a drop down to control the values that go into a
particular column?
 
G

Guest

i = DataGridView.CurrentRow.Index
If rows = 0 Then
i = OrderDetailsDataGridView.Rows.GetRowCount
DataGridViewElementStates.Displayed) - 1
End If
DataGridView.Item(0, i).Value = Me.combobox.selectedvalue.tostring()

where 0 is the column and i is the row
 

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