3

I am retrieving data from MySQL database and show in Gridview.For that GridView Control I want to edit that particular data which is displaying in the grid

if I click on a particular row then the data should display in a popup window and should display the selected record data in popup window. after editing and saving the data i want the GridView to update.

how can I implement this feature in my winform app.

thanks in advance.

Damith
  • 62,401
  • 13
  • 102
  • 153
  • I think you should look for a custom built grid view to achieve what you want – COLD TOLD Jun 19 '12 at 05:24
  • winforms passing data between 2 froms http://stackoverflow.com/questions/7800731/passing-data-between-winforms-forms, unlike him i am not afraid to put props in the pop-up, just dispose it afterwards – bresleveloper Jun 19 '12 at 06:47

1 Answers1

0

You'll need to create another form to display all of that information. In the constructor of the form, take in either a data object that holds all of the data in the Gridview, or just pass in the data from the row as individual strings, ints, DateTimes, whatever. In the Save button event, save the data to the underlying database table.

Then set up the GridView for FullRowSelect. In the CellClick event, first create the object (if you have one) by using the properties of the EventArgs to find what row was selected.

Still inside the CellClick event, create a new form object of the one you created to show the data, and pass in the data of the row. Something like:

frmShowDetails form = new frmShowDetails();
form.ShowModal();

LoadDataGrid();

The ShowModal is key, as it will lock the rest of your program until they are done with that new form. The LoadDataGrid method will be where you clear the DataSource for your DataGrid and repopulate the entire thing from the Database (you can also call that in this form's Load event so you don't duplicate code).

Let me know if you need any more code, and I'll add it once I get into work.

krillgar
  • 12,596
  • 6
  • 50
  • 86