I'm working on winforms for the first time. I want a datagrid to display the data and be able to edit and update the same. It displays the data. But, I have not been able to make the Datagrid editable. Can anybody please gimme some quick tips for this or best gimme a link for how to edit the data in a winform datagrid?
Hope this helps. If it does, then rate it.
----
Rohit
The data is surely from a database and I load my database using a custom collection class I have created. Also, I need to know what do I need to make my grid eidtable (find the selected row or inline editing etc. as in ASP.Net).
Hope this helps. If it does, then rate it.
----
Rohit
Inserting/Updating/Deleting Records using DataGrid
Code:
dataset ds = new dataset();
OleDb.OleDbConnection con = new OleDb.OleDbConnection(yourconnectionstring);
OleDb.OleDbDataAdapter da = new OleDb.OleDbDataAdapter("select * from yourtable", con);
da.fill(ds);
datagrid1.datasource = ds.tables(0);
Now you can add/delete/update the records in your datagrid. To save the changes you made back to the database
do something like (like behind a save button)
Code:
OleDb.OleDbCommandBuilder cm = new OleDb.OleDbCommandBuilder(da);
da.update(ds);
u bound the datagrid with the datatable
then make modifications in the datagrid.
when u are ready to set the change to the database as until now u have modified the datatable.
press update(button) it creates the commandBuilder for the dataAdapter and then updates the database.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.