Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > New Row
 

New Row

In a datagridview, when you select the last row, it is marked with an * in the left hand column and when you update the table adapter manager, the datagridview knows to run the insert method. Is there a way to programatically mark a row as new? For instance, I have a datagridview full with data and an extra column at the end that is empty when the view is filled. I would like the row to become marked as "new" any time a value is entered in the extra column at the end. Is this possible?
MethodMas  Tuesday, September 08, 2009 4:38 PM
There is a SetAdded() method in the DataRow class but i'm not sure if this is what you need.
Christoph Wagner  Wednesday, September 09, 2009 7:13 AM
There is a SetAdded() method in the DataRow class but i'm not sure if this is what you need.
Christoph Wagner  Wednesday, September 09, 2009 7:13 AM
This sounds like it may work, but I can't figure out the context to put it in. I've tried a bunch of things (the tableadapter, the datagridview, the data table in the dataset). But none of these recognize the SetAdded method.
MethodMas  Wednesday, September 09, 2009 4:41 PM
Hi MethodMas,

Please look at this document
http://msdn.microsoft.com/en-us/library/system.data.datarow.setadded.aspx

For example:
this.dataSet1.Tables[0].Rows[0].SetAdded();
This code will set the first row in the first table in DataSet1 as an Added Row. The RowState of it will be "DataRowState.Added ".

Is this what you are looking for?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, September 10, 2009 5:33 AM
in this example, you can not code this.dataSet1.Tables[0].Rows[0].SetAdded();
because you get the following error:

Value of type 'System.Data.DataTableCollection' cannot be converted to 'System.Data.DataRow'.

MethodMas  Monday, September 21, 2009 9:19 PM
Hello,

Does the first row in the first table in the dataset is the one you want to change RowState?
Here is the document about DataRow.SetAdded Method
http://msdn.microsoft.com/en-us/library/system.data.datarow.setadded.aspx

If you have any question, please post your code. That can help us to find a better solution.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Tuesday, September 22, 2009 1:58 AM

You can use google to search for other answers

Custom Search

More Threads

• inheritance bindingsource
• Databinding to textboxes on form using SQLExpress
• Providing customozed Hyper Link
• How can I display fields from a Table into a ComboBox?
• DataRelations and ComboBox Data binding
• How to display datetimepicker in a cell of a datagridview?
• Please Help - custom objects/collections and datagrids
• Populating VB.Net Listview from Access Database
• Changing DataBound values w/o Changing Focus
• Fax service in WIndows XP to enable sending faxes in VB 2005