groupBox that looks like a modal form

  • Thread starter Thread starter touf
  • Start date Start date
T

touf

Hi,
I've a groupBox that I use like a form (textBox, button Ok and button
Cancel) that is hidden at the starting (visible=false),
It is activated (visible=true) when I clic on a buttton, and hidden when I
clic on its OK or Cancel Button.

I like to give it the behaviour on a modal form, that means that the user
can't work on the onther controls while this groupBox is displayed.
Any Idea please.
 
OnActivate of the GroupBox, iterate through the form's controls collection.
Container controls are conisdered independently, so if you had a panel, a
groubox each having 10 controls on them, and 10 textboxes on a form, the for
would have 12 controls if you enumerated them.

Anyway, when the activation changes, ie GotFocus, LostFocus, call a function
that sets the enabled or visible state of each of the other controls to the
opposite of the visible property of the groupbox.

Dim c as control

For each c in MyForm.Controls
c.Enabled (or Visible) = NOt myGroupBox.Enabled (or Visible)
Next
Just negate the enabled for visible property of each control you iterate
through.

Now, if you have stuff on panels or group boxes other than the one you are
on, you'll need to iterate through the controls collection in each of those
containers, but the logic is essentially the same.

HTH,

Bill
 
touf said:
I've a groupBox that I use like a form (textBox, button Ok and button
Cancel) that is hidden at the starting (visible=false),
It is activated (visible=true) when I clic on a buttton, and hidden when I
clic on its OK or Cancel Button.

I like to give it the behaviour on a modal form, that means that the user
can't work on the onther controls while this groupBox is displayed.
Any Idea please.

Put all the other controls into a container (for example a panel). Then
you set the container's 'Enabled' property to 'False' and position your
groupbox in front of the container (notice that the control must not be
placed _inside_ the container). You can bring a control to front by
calling its 'BringToFront' method.
 
Back
Top