how to add a new row to datagridview + bound text boxes et

I have a datagridview(too small to put all the column values) so I used some text boxes in a form below to display the entire detail for any selected row. The textboxes are bound to the same databindingsource as the datagridview..The selected row in datagrid populates values in the textboxes.

I want some mechanism so that when a user wants to add a row, they can put their values in the textboxes and hit add button which puts the new row in the datagridview. Is this possible?

Thanks..

[507 byte] By [ChitownDotNet] at [2007-12-22]
# 1

HI,

Yes, definitely its possible! Just add a new empty row in your underlying datatable and your datagridview would automatically have an empty row within.

cheers,

Paul June A. Domag

PaulDomag at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 2

You can use an ADO.net object with a submit button that binds with the same recordset.

So when the user submits a record through the associated text boxes, it grdview.databinds()

Problem solved.

Adamus

AdamusTurner at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 3

Paul,

The bigger problem is in the UI aspect. The textboxes are bound to the same databindingsource as the datagridview. For the user to be able to add a new item, I am not able to provide them with textboxes which are completely cleared out.

The textboxes always display the detail from the current selected item in the datagridview. If I programatically, try to do this by selecting a new row in the datagridview, then having the user to edit that empty row(the textboxes still pick up the values from the last row in the datagridview..).

Bottom line, I can't get empty non bound textboxes so that user can use it as a regular data entry form.

Thanks

Nik

ChitownDotNet at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 4

Hi,

If the UI aspect that you are concerned with then you can add a new entry form (to handle new entries) just show it when the user presses the new button then pragramatically add it to your datatable after the user finishes inputing values in your entry form.

cheers,

Paul June A. Domag

PaulDomag at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 5
I am trying to edit the values using the same textboxes. Since I don't want to have a new form to edit values only. So essentially I have one datagridview, and one set of corresponding textboxes for each column. Any ideas?
ChitownDotNet at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 6

Hi,

What about unbinding these textboxes and clear these textboxes. After that you can manually set the values in the textboxes into your datatable and then bind the textboxes again.

cheers,

Paul June A. Domag

PaulDomag at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...