Form initial display issue

R

Rod

I have a form display issue that surely others have encountered and
have resolved. I couldn't find any posts about it, which I attribute
to my inability to describe it well.

I have an MDI application that opens every MDI child form maximized.
These child forms generally contain a DataGridView control with the
associated Binding Navigator at the top of the form. The navigator is
anchored Top,Left, and the DataGridView is anchored to all sides.

When the form opens, the DataGridView does not fill the entire form,
rather there is a line about 1/2 inch from the bottom of the
application window. If I resize the application window at all, the
deformity goes away and my form looks as it should.

How can I get my form to appear as it should when first displayed (with
the DataGridView filling up the whole form except for the Binding
Navigator)?

Thanks,
Rod Early
 
P

Pritcham

Hi

If, when you're designing the form, you add the BindingNavigator first,
set it's Dock property to "Top", then add your gridview, and set it's
Dock property to "Fill" it should be fine.

FYI, Anchoring is more about fixing the distance a control is from the
edges of a form/container (i.e. if you anchor a control to Top/Left
then the control should stay the same distance away from each of these
edges when you re-size the form). Docking is more geared towards how
much space (and where) the control will take up in the form/container.
(In my mind anyway)

Hope that helps
Martin
 
R

Rod

Martin:

I tried using the Doc property as you suggested but I still get the
same effect. My controls don't look correct until I "resize" the
window.

Thanks,
Rod
 
P

Pritcham

Hi

I'm not actually at a development machine at the moment so can't try to
recreate etc but it may be something to do with how you're opening up
your child windows (it shouldn't affect it but from what you've said,
any resizing will correct the issue so it kind of looks like it isn't
refreshing/painting the controls properly on load). As a quick test,
have you tried adding a form.Refresh (or form.Repaint) call after the
child form has loaded? That may help (but as I can't test it I can't be
sure).

Cheers
Martin
 
R

Rod

Martin:

I have a solution, as follows:

1. Specify the WindowState property on the child form (window) to be
"Normal".
2. After instantiating the form, but before showing it, set its
WindowState to Maximized.
3. Show the form. The controls (such as datagrids) have expanded to
their maximized positions, as I expected.

To reiterate, I had to change the WindowState from Normal to Maximized
before showing it -- presumably the change of state caused the
application to put everything it its proper place.

Thanks,
Rod
 
P

Pritcham

Glad you got it sorted Rod - bit of a nuisance having to do that but
hey - if it gets the job done...!

Cheers
 

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