control array

B

bz

Hi,

I am still using vb6. The project is too big to just copy and paste it to
VB.NET. I think I need to rewrite everything.
One question is:

If there is no control array, is it better to just create the bunch of
button objects from one button control rather than just drag and drop a
bunch of buttons on the screen?
 
R

RobinS

It doesn't matter. The only benefit to creating one button
control and copying and pasting it multiple times is that
all of them will be the same size. But you can get the same
thing by selecting all of them and using the menu options
to make them the same size.

The question is why are they in a control array; what are you
doing with them?

You can add them to a generic list and access them that way,
or you can cycle through all the controls looking for them,
and identify them by the fact that they are buttons, or by
the value you place in the Tag field. If you need to know how
to do that, re-post and I (or someone else) will post the
code for that.

Good luck.
Robin S.
 
M

Martin Milan

It doesn't matter. The only benefit to creating one button
control and copying and pasting it multiple times is that
all of them will be the same size. But you can get the same
thing by selecting all of them and using the menu options
to make them the same size.

The question is why are they in a control array; what are you
doing with them?

You can add them to a generic list and access them that way,
or you can cycle through all the controls looking for them,
and identify them by the fact that they are buttons, or by
the value you place in the Tag field. If you need to know how
to do that, re-post and I (or someone else) will post the
code for that.

Good luck.
Robin S.

Hi again Robin,

I was under the impression that dotnet controls didn't have tag
properties...

Martin
 
R

rowe_newsgroups

I was under the impression that dotnet controls didn't have tag
properties...

At least in the .Net 2.0 controls have the tag property. If they don't
then the project I used them in today is in bad shape :)

Thanks,

Seth Rowe
 
R

RobinS

Martin Milan said:
Hi again Robin,

I was under the impression that dotnet controls didn't have tag
properties...

Martin

As noted by Seth, they *do* have the property [Tag]. And
thank goodness they didn't get rid of *that*!

Robin S.
 
M

Martin Milan

As noted by Seth, they *do* have the property [Tag]. And
thank goodness they didn't get rid of *that*!

Robin S.

Was it supported in 1.0 and 1.1?

The reason I thought it had gone is that once again I've been reading a
VB6 to dotnet conversion text (and old one though) which said they had
gone. Our VB6 project makes plenty of use of tag as well...

Martin
 
S

Stephany Young

Yes. Tag has been a property of the System.Windows.Forms.Control since .NET
Framework 1.0.

This means that any class derived from System.Windows.Forms.Control
automatically has it.

However, a class derived from System.Windows.Forms.Control may override the
Tag property of the base class and implement it in a different way, e.g.:

Public Overrides Property Tag() As Object
Get
Throw New Exception("Not implemented.")
End Get
Set(value As Object)
Throw New Exception("Not implemented.")
End Set
End Property

Why anyone would want to do so escapes me, but it is possible.

There are a multitude of classes on the Framework that, of course, are not
derived from System.Windows.Forms.Control, and any of those may or may not
expose a Tag property depending on who wrote the class, how they were
feeling at the time and whether or not the month had a 'y' in it, etc.


Martin Milan said:
As noted by Seth, they *do* have the property [Tag]. And
thank goodness they didn't get rid of *that*!

Robin S.

Was it supported in 1.0 and 1.1?

The reason I thought it had gone is that once again I've been reading a
VB6 to dotnet conversion text (and old one though) which said they had
gone. Our VB6 project makes plenty of use of tag as well...

Martin
 

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