upon the Add Record button is pressed, I want to display the last row in the DataGrid. What is the code necessary?
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sukesh MarlaPosted Oct 16, 2012, 11:04 PM
List
..
..
..
datagridview1.datasource=MyList;
..
..
..
After Save
List MyList=(List)datagridview1.datasource;
MyClass m=new MyClass();
m.Property1=InsertValu1;
.
.
.
MyList.add(m);
TAN WhoAMIPosted Oct 16, 2012, 8:32 PM
Sukesh MarlaPosted Oct 15, 2012, 11:07 PM
TAN WhoAMIPosted Oct 15, 2012, 8:35 PM
Sukesh MarlaPosted Oct 15, 2012, 5:02 AM
Use following syntax;
datagridview1.datasource=mydt;
.
.
.
After Save
DataTable mydt=(DataTable)datagridview1.datasource;
DataRow dr=mydt.NewRow();
dr["Col1"]=InsertValu1;
mydt.Rows.add(dr);
you can see last row is reflecting new row.
Check this is corrrect answer if it helped