On 3/26/2010 11:24 AM, sajit wrote:
> On Mar 26, 4:46 pm, Family Tree Mike<FamilyTreeM...@ThisOldHouse.com>
> wrote:
>> 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
>
> hi mike I think u r getting me wrong. I am filling datagridview at run
> time. The size can grow or shrink depending on the item selected from
> combo box. The problem is datagridview is showing records on the size
> I defined at design time, other records are only viewed by clicking on
> scroll bars. Is there any property or event I can use to resize
> datagridview dynamically.
Actually, you are now describing what I thought I understood, and
described as a bad thing. My understanding is that you have a form, and
based on a combo box selection, a datagridview is filled with many rows.
You want the datagridview to be large enough so there is no scrollbar.
It is a bad thing to have a control grow like this for the user.
Users expect scrollbars on these things when there are many rows.
If you insist on changing the size of the datagridview, you would need
to use the RowHeight property to multiply by the number of rows to
change the control height.
--
Mike
|