From: sajit on
hi folks,
i am bit new to vb.net. My issue is, I have placed a datagridview
control on my win form. I am loading data into it as per user
selection from combo box. but issue is only few records are visible on
form, to view other record i have to manually click on vertical scroll
bars. Is there any way to fit the datagridview to show all records
without using scroll bars?
From: Family Tree Mike on
On 3/26/2010 7:34 AM, sajit wrote:
> hi folks,
> i am bit new to vb.net. My issue is, I have placed a datagridview
> control on my win form. I am loading data into it as per user
> selection from combo box. but issue is only few records are visible on
> form, to view other record i have to manually click on vertical scroll
> bars. Is there any way to fit the datagridview to show all records
> without using scroll bars?

Yes, you can adjust the size of the control on the change of the
combobox, but I recommend against that. It is very unusual in any
application for a control to grow/shrink based on a change of a value.
The recommended way to handle this would be setting the initial size of
the control to a reasonable proportional size for the form, and
anchoring the control to four sides. This way, the user can expand or
shrink the form, and the control will grow/shrink with it.

--
Mike
From: Phill W. on
On 26/03/2010 11:34, sajit wrote:

> issue is only few records are visible on form, to view other record
> I have to manually click on vertical scroll bars.
> Is there any way to fit the datagridview to show all records
> without using scroll bars?

To have the DataGridView (or any other Control for that matter) resize
along with your Form, experiment with the Anchor property.

If the DataGridView is inside another container (e.g. a Panel), try
setting the Dock property to "Fill".

You may still need the scroll bars - that just depends on how much data
you put into it.

HTH,
Phill W.