Showing posts with label DataGridView. Show all posts
Showing posts with label DataGridView. Show all posts

Tuesday, May 12, 2009

Export DataGridView into .csv file

Following example I am trying to save the DataGridView's Data into .csv file

Please create a Windows Application and Add a DataGridView and a button on Form1, to fill the data initially please add following code in Form1_Load

image

Double click on the Button and add following code in Button1_Click, in this code we are reading all columns and rows and forming a string and saving in data.csv file

image

Now we are ready with our code, just build, run and test.

Tags: Export DataGridView to .csv file, Windows Forms, C#, .NET

Saturday, May 9, 2009

Getting the Selected Value of Combo Box in DataGridView

In following example I am try to get the Selected value of Combo Box which is in DataGridView.
Create a Windows Applicaiton and Add a DataGridView in the Form1

We need to initialise DataGridViewEditingControlShowingEventHandler of DataGridView to handle its control events, so please use follwoing code in Forms Constructor

image

In the form load we will fetch all the data and assign to DataGridView

image

Now catch the control edit event in the DataGridView and assign the SelectIndexChanged event to each Combo Box in DataGridView

image

Add Follwoing Combo Box's SelectedIndexChanged which we assigned to all the combo boxes in DataGridView

image

Now we are ready with our code lets build, run and test.

Output:

image

Tags: Getting the Selected Value of Combo Box in DataGridView, DataGridView