|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
auto sizing data grid viewhi 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? On 3/26/2010 7:34 AM, sajit wrote:
> hi folks, Yes, you can adjust the size of the control on the change of the > 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? 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 On Mar 26, 4:46 pm, Family Tree Mike <FamilyTreeM***@ThisOldHouse.com>
wrote: Show quoteHide quote > On 3/26/2010 7:34 AM, sajit wrote: hi mike I think u r getting me wrong. I am filling datagridview at run> > > 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 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. On 3/26/2010 11:24 AM, sajit wrote:
Show quoteHide quote > On Mar 26, 4:46 pm, Family Tree Mike<FamilyTreeM***@ThisOldHouse.com> Actually, you are now describing what I thought I understood, and > 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. 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 Sajit,
Be careful though - based on my experience doing something similar with programmatically creating buttons on a panel, if you make the datagrid large enough to accomodate all of the rows, and there are more rows in the datagrid than will appear on the form, you may not get any scroll bars at all, and then users have no way of getting at the records that flow off the form... FWIW Patrick On 26/03/2010 11:34, sajit wrote:
> issue is only few records are visible on form, to view other record To have the DataGridView (or any other Control for that matter) resize > 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? 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.
Show quote
Hide quote
On Mar 26, 5:11 pm, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k> hi Phill I think u r getting me wrong. I am filling datagridview atwrote: > 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. 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.
Execute an executable program.
common ways creating projects. SQLDataAdapter Fill with startRecord parameter Can You Save the DataGridView Sort Order / Update the Underlying DB? How to navigate through dataset Acessing DLL members which differ only in Case from VB.net Minimise button on title bar and resize Reference to a DLL on the network Insert Record in DataContext without upgrading the database Context Menus |
|||||||||||||||||||||||