How do I add various numbers of datagridview
I work in Visual Studio 2010 and I have a list with a various number of
items - sometime the list have five items, sometimes seven items,
sometimes ni items, etc. This list is created based on some
filter-settings made by the user and saved in a datatable. I need to add a
datagridview for each item in the list.
So I need to declare a various number of datagridviews, set the size and
add them. If I only had one item I would use following code:
Dim dgv_1 As New DataGridView
dgv_1.Size = New Size(100, 100)
dgv_1.Location = New Point(10, 10)
As the requried number of datagridviews various, I would like to make a
for-loop that does the above and please then one under another like below:
for x = 1 to number_of_items
dim dgv_x As New DataGridView
dgv_x.Size = New Size(90, 90)
dgv_x.Location = New Point(10, 10 + 100 * x)
next
I am aware that above does not work, so I am looking for the correct way
to write a code that does this and I was hoping that someone could assist
me with this, as I am stuck at the moment in my coding.
No comments:
Post a Comment