E
eBob.com
How do I set the Height of a DataGridView to just accomodate what I've put
in it? Not too big, not too small.
I looked for a property which I could set such that the Height would grow as
I added rows. But found no such property.
So I thought, OK, I can calculate the value, after populating the
DataGridView, like this ...
MasterSegs(cmsi).Height = (MasterSegs(cmsi).Rows.Item(0).Height *
MasterSegs(cmsi).Rows.Count) _
+ MasterSegs(cmsi).ColumnHeadersHeight
(All rows are the same height and there is always at least one row.)
But that creates extra space within the control but beyond the last row. In
one case I was able to set exactly the right size by getting rid of the
vertical scroll bar. But in another case getting rid of the vertical scroll
bar made no difference - there is still unused space beyond the last row.
I even tried subtracting 1 and even 2 from the Rows.Count but that didn't
seem to make any difference.
This is really annonying as I am trying to layout consecuitive DataGridViews
in a Panel and I don't know how to specify the Y locations of the
DataGridViews.
My searches found that this problem comes up from time to time but I have
not found a solution posted.
Thanks, Bob
in it? Not too big, not too small.
I looked for a property which I could set such that the Height would grow as
I added rows. But found no such property.
So I thought, OK, I can calculate the value, after populating the
DataGridView, like this ...
MasterSegs(cmsi).Height = (MasterSegs(cmsi).Rows.Item(0).Height *
MasterSegs(cmsi).Rows.Count) _
+ MasterSegs(cmsi).ColumnHeadersHeight
(All rows are the same height and there is always at least one row.)
But that creates extra space within the control but beyond the last row. In
one case I was able to set exactly the right size by getting rid of the
vertical scroll bar. But in another case getting rid of the vertical scroll
bar made no difference - there is still unused space beyond the last row.
I even tried subtracting 1 and even 2 from the Rows.Count but that didn't
seem to make any difference.
This is really annonying as I am trying to layout consecuitive DataGridViews
in a Panel and I don't know how to specify the Y locations of the
DataGridViews.
My searches found that this problem comes up from time to time but I have
not found a solution posted.
Thanks, Bob