0

I have some data and I want to add to data Grid View.I want enter data from C# program-me code.I don't want to send them into database.When i enter some name from code I should appear in data Grid view.How can i do this?

D M L K Sandanuwan
  • 159
  • 2
  • 5
  • 13
  • possible duplicate of [c# How to add a new row to datagridview programmatically](http://stackoverflow.com/questions/10063770/c-sharp-how-to-add-a-new-row-to-datagridview-programmatically) –  Dec 14 '13 at 20:16
  • My question is very simple.when i run my project i can display Massage boxes from MessageBox.Show(print.Name+":"+print.PrinterStatus.ToString()+":"+print.PrinterStatus+":"+print.Shared); . Now I want appear those data in datagridview. – D M L K Sandanuwan Dec 14 '13 at 20:31

2 Answers2

1

You can add a new row with data to your DataGridView:

DataGridViewRow row = (DataGridViewRow)yourDataGridView.Rows[0].Clone();
row.Cells[0].Value = "XYZ";
row.Cells[1].Value = 50.2;
yourDataGridView.Rows.Add(row);
Yair Nevet
  • 12,725
  • 14
  • 66
  • 108
0

You can do something like, following code would set the value to row 0 and column 0. If you want to set the value to different cell then adjust the Row and Cell index.

dataGridView1.Rows[0].Cells[0].Value = "some value";
Kurubaran
  • 8,696
  • 5
  • 43
  • 65