2

I have a DatagridView in which the first column is fixed and has TextBoxes. The second column has ComboBoxes. All of the rows at the second column have 4 choices(name, surname, address, date).

When the user chooses from the ComboBoxes and presses a button, I need to take the values of the second column and put them in a new string[].

So if the user chooses :

name,
surname,
name,
date,

They are put in a string array named FromDataGrid[]. As far as now I have made this:

private void button2_Click(object sender, EventArgs e) {
    string[] colB = new string[dataGridView1.Rows.Count];
6
  • possible duplicate of C# datagridview column into an array Commented Jul 26, 2011 at 9:46
  • kak ylia's answer is more simple. But not big difference. Commented Jul 26, 2011 at 10:51
  • if Kak Ylia's answer works for you, you should mark it as accepted. Commented Jul 26, 2011 at 11:47
  • @david Of course I will mark it as accepted. But I am waiting him to accept my edit. It says "This edit will be visible only to you until it is peer reviewed." Commented Jul 26, 2011 at 12:25
  • ah sorry, didn't notice that there was a pending edit. Commented Jul 26, 2011 at 12:40

1 Answer 1

1

Something like that:

for (int i = 0; i < dataGridView1.Rows.Count; i++)
    colB[i] = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.