barranr
8/9/2007 6:08:00 PM
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
"Patrick" wrote:
> 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?
>
> "barranr" wrote:
>
> > look at DataGridView_DefaultValuesNeeded and DataGridView_CellFormatting
> >
> > "Cor Ligthert[MVP]" wrote:
> >
> > > 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
> > >
> > > "Patrick" <patl@reply.newsgroup.msn.com> schreef in bericht
> > > news:F2AAC264-A6EF-4F29-A7CC-0D178B90D1F8@microsoft.com...
> > > > 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?
> > > >
> > > >
> > > > "Cor Ligthert [MVP]" wrote:
> > > >
> > > >> Patrick,
> > > >>
> > > >> Always try to access a DataGrid using the underlying dattable.
> > > >>
> > > >> Cor
> > > >>
> > > >> "Patrick" <patl@reply.newsgroup.msn.com> schreef in bericht
> > > >> news:C2094410-090C-4764-85BD-DAC6032672D1@microsoft.com...
> > > >> > In addition, how could I control values that are allowed in another
> > > >> > cell
> > > >> > value with a drop-down control?
> > > >> >
> > > >> > "Patrick" wrote:
> > > >> >
> > > >> >> 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?
> > > >>
> > > >>
> > > >>
> > >
> > >