user control with a datagrid control in it

D

David C

I have a user control with a datagrid in it.

Here is what I would like to do

* As the width of the datagrid grows or shrinks, have the user control
adjust so that it always looks full in the user control with no
scrolls. The datagrid's columns can be hidden or shown at run time,
so I cannot predict what the width will be until runtime.

* Also have that user control always centered.

In other words, I am trying to emulate how user controls behave on the
Web. Thank you.
 
G

Guest

First the first one, you would need to set the Usercontrol properties in the
usercotnrol designer to autosize=true, and AutoSizeMode = GrowAndShrink.
Then handle the columns added, columns removed, columnresized events on the
datagridview and set the size of the grid to the PrefferedSize property. That
is the size it would be to have no scroll bars.

For always centred. Centre it in the designer (theres a toolbar item for
that), then change the Anchor to be top (no left or right) and it will stay
in the centre,

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top