Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Adding Rows in DataGridView on form without writing the syntax DataGridView1.Rows.Add(3)

$
0
0

The thread question is clear and specific ie. to add rows in DGV1 on Form without writing its syntax (programmatically

The reason i want is to work around with cells in DGV1 is for Numbering cells its Location and sizeAlso the Cells in DGV1 are square as per below code

DataGridView1.Rows.Add(3)For i As Integer = 0 To DataGridView1.Rows.Count - 1            DataGridView1.Rows(i).Height = 76        Next i  For i As Integer = 0 To DataGridView1.Columns.Count - 1            DataGridView1.Columns(i).Width = 76        Next i

so when i add 3 rows as per above i get Row 1 on Top with valuesRow 2 in Middle with values andRow 3 in Bottomwith following syntaxes

DataGridView1.Rows(0).Cells(1).Value ="1"DataGridView1.Rows(0).Cells(2).Value ="2"DataGridView1.Rows(0).Cells(3).Value ="3"DataGridView1.Rows(1).Cells(1).Value ="4"DataGridView1.Rows(1).Cells(2).Value ="5"DataGridView1.Rows(1).Cells(3).Value ="6"DataGridView1.Rows(2).Cells(1).Value ="7"DataGridView1.Rows(2).Cells(2).Value ="8"DataGridView1.Rows(2).Cells(3).Value ="9"

and by default the columns are three without adding and removing on the DGV1 property.Ultimately it looks like below

1 2 34 5 67 8 9

Basically wanted to re-shuffle the above cells on the Form with above respective values placed differently with further coding i can get its values respectfully. So i thought of placing the cells manually to get the respective values in each cell numbered correctly

4 9 28 5 73 1 6

ThanksSsD

Explored on the DGV1 property box if possible to get Cell of DGV1 manually on the form.I could not find the same to implement it


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>