04 June 2014

Display Cell Value into ListBox in C#.Net

Add  DataGridview,Button  and ListBox in your form.
Create  one method for getting Particular Cell data for listbox:

void DisplayCellDataintoListBox(int cellId)
{ foreach (DataGridViewRow row in dataGridView1.Rows)
{ listBox1.Items.Add(Convert.ToString(row.Cells[cellId].Value));
}
}

Call this method in the Button Click event:
DisplayCellDataintoListBox(<Pass Datagridview CellId>);

No comments: