Q: controls in a panel

  • Thread starter Thread starter Geoff Jones
  • Start date Start date
G

Geoff Jones

Hi

I have added a panel to a form and in this panel have added some controls
e.g. Button1

The only way I can see to access this button is as follows:

Dim index As Integer = Me.Panel1.Controls.IndexOf(Button1)
CType(Me.Panel1.Controls.Item(index), System.Windows.Forms.Button).Enabled =
True

Is there an easier way to do this? It seems a lot of typing!

Also, the button seems to be disabled even if this code is used; although it
is visible. Can anybody help?

Thanks in advance

Geoff
 
Geoff,

This is strange, the button should be directly reachable with "button1"

In you situation I would delete it from the form it and drag it again on the
panel.

I hope this helps?

Cor
 
Geoff Jones said:
I have added a panel to a form and in this panel have added some controls
e.g. Button1

The only way I can see to access this button is as follows:

Dim index As Integer = Me.Panel1.Controls.IndexOf(Button1)
CType(Me.Panel1.Controls.Item(index), System.Windows.Forms.Button).Enabled
=
True

Is there an easier way to do this? It seems a lot of typing!

LOL! You first determine the index of the button by already having a
reference to it and then get back the reference by a lookup by index. You
can replace the code above with this:

\\\
Me.Button1.Enabled = True
///
 
D'OH! LOL

Thanks guys

Geoff

Herfried K. Wagner said:
LOL! You first determine the index of the button by already having a
reference to it and then get back the reference by a lookup by index. You
can replace the code above with this:

\\\
Me.Button1.Enabled = True
///
 

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

Back
Top