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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sukesh MarlaRank #461 · 5.4K reputationPosted Oct 15, 2012, 1:02 AM EDT
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
TAN WhoAMIRank #5,790 · 286 reputationPosted Oct 15, 2012, 4:35 PM EDT
Sukesh MarlaRank #461 · 5.4K reputationPosted Oct 15, 2012, 7:07 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Oct 16, 2012, 4:32 PM EDT
Sukesh MarlaRank #461 · 5.4K reputationPosted Oct 16, 2012, 7:04 PM EDT
List
..
..
..
datagridview1.datasource=MyList;
..
..
..
After Save
List MyList=(List)datagridview1.datasource;
MyClass m=new MyClass();
m.Property1=InsertValu1;
.
.
.
MyList.add(m);