473,848 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can we define control array in VB.Net

Hello,
anyone can guid me how we can handle and define control array in vb.net?

Thanks & regards

SARFARAZ KHAN
Nov 21 '05 #1
9 6103
* "Sarfaraz Khan" <sa******@algha nem.net> scripsit:
anyone can guid me how we can handle and define control array in vb.net?


<URL:http://groups.google.d e/groups?selm=%23 TBRYhyaEHA.904% 40TK2MSFTNGP09. phx.gbl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Sarfaraz,

Dim ctrArea As Control() = New Control() {me, Button1, Etc}

I think you are not after that, however than you have to tell more?

Cor
anyone can guid me how we can handle and define control array in vb.net?

Nov 21 '05 #3
Sarfaraz,

If you mean adding controls dynamically to a form, you do it in the code:

Create a control object at the module level (before the Windows Form
Designer generated code):

Private MyLabel as Label

Then, after InitializeCompo nent, or in the Load event, set the position and
visibility of the control and add it to the Controls collection of the Form:

With MyLabel
.Top = 40
.Left = 40
.Visible = True
End With
Me.Controls.Add (MyLabel)

That's it. Now, to have an ARRAY of controls, create an array at the module
level:

Private MyLabels as Label()

Then in the Load event, execute similar code for each of the objects in the
array:

Dim i as Integer

ReDim MyLabels(9)
For i = 0 To 9
MyLabels(i) = New Label
With MyLabels(i)
.Top = (i * 40) + 40
.Left = 40
.Visible = True
End With
Me.Controls.Add (MyLabels(i))
Next i

In order to change your control later in the form, just call your
module-level object:

MyLabels(5).Tex t = "Some New Text"

Hope this helps.
--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com
"Sarfaraz Khan" <sa******@algha nem.net> wrote in message
news:er******** ******@TK2MSFTN GP10.phx.gbl...
Hello,
anyone can guid me how we can handle and define control array in vb.net?

Thanks & regards

SARFARAZ KHAN

Nov 21 '05 #4
If you are trying to create a common handler for a series of controls you
can modify the handle statement(s) at the end of each event handler:

For example:
Private Sub TextBox1_TextCh anged(ByVal sender as System.Object, ByVal e
As System.EventArg s) Handles TextBox1.TextCh anged, TextBox2.TextCh anged,
TextBox3.TextCh anged etc.

Dim ltxtBox as TextBox
ltxtBox = CType(sender, TextBox)

Select Case ltxtBox.Name
Case "TextBox1"
'do something
Case "TextBox2"
'do something
End Select

End Sub

"Sarfaraz Khan" <sa******@algha nem.net> wrote in message
news:er******** ******@TK2MSFTN GP10.phx.gbl...
Hello,
anyone can guid me how we can handle and define control array in vb.net?

Thanks & regards

SARFARAZ KHAN

Nov 21 '05 #5

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..

<URL:http://groups.google.de/groups?selm=...K2MSFTNGP09.ph
x.gbl>

"In VS.NET 'Whidbey' (2005) control arrays will be supported natively"? I
hadn't heard about that. where might I find info on this particular subject?
Is it as simple as cracking open the scaled-down MSDN that came with the
beta and looking up "control array"? (I don't have the VPC that I'm running
Whidbey in up at the moment, nor even the computer that runs it, or I'd
check myself.)
Nov 21 '05 #6
* "Jeff Johnson [MVP: VB]" <i.***@enough.s pam> scripsit:
<URL:http://groups.google.de/groups?selm=...K2MSFTNGP09.ph
x.gbl>

"In VS.NET 'Whidbey' (2005) control arrays will be supported natively"? I
hadn't heard about that. where might I find info on this particular subject?


I remember there was support in the PDC build, but I didn't check that
in the newer builds.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7
replacement of these code into VB.Net?

Private Sub Command1_Click( index as integer)
Select Case index
Case 0
'Some Code
Case 1
'Some Code

End Select
End Sub
and how i place control on the form that make automaticaly control array
like in VB 6

Thank & Regards
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #8

"Sarfaraz khan" <nu*******@hotm ail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
replacement of these code into VB.Net?

Private Sub Command1_Click( index as integer)
Select Case index
Case 0
'Some Code
Case 1
'Some Code

End Select
End Sub
Private Sub CommonButtonCli ckHandler(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles AddButton.Click , DeleteButton.Cl ick[, ...]
If sender Is DeleteButton Then
' Do something
ElseIf sender Is AddButton Then
' Do something else
[etc.]
End If
End Sub
and how i place control on the form that make automaticaly control array
like in VB 6


You don't. .NET has done away with the VB6 concept of control arrays.
Nov 21 '05 #9
Sarfaraz,
and how i place control on the form that make automaticaly control array
like in VB 6

As Jeff stated you can not do it the same way, however you can place your
control in every array and than process it like that. A simple one
\\\
Dim ctrArr as new Arraylist
ctrArr.Add(myBu tton1)
dim buttonname as string = directcast(ctrA rr(0),button).n ame
///

So you can make as much controlarrays as you want.

I hope this helps?

Cor
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
3700
by: Dennis | last post by:
I would like to dynamically allocate in a sub a 2 dimensional Array float *myarray = new float ; of course I get an error. How do you allocate a 2D array using the New operator? I currently use static float gxy;
7
29282
by: Roman Mashak | last post by:
Hello, All! I wonder is it possible to define an array containing strings, not single characters? What I want is array 'table' that will have N elements, and every element is a strings tailoring with '\0', like that: table = "string0\0" table = "string1\0" ...
5
11448
by: Stuart Norris | last post by:
Dear Readers, I am attempting to define an array of IPAddress-es in C#. I wish to have a array of address so I can try in order to connect to them in a loop to handle unavailable hosts. Todate since I do not know how to define an array of IPAddress-es. I have been defining variable like:
29
2339
by: Ancient_Hacker | last post by:
It sure would be nice if I could have a macro that add a level of indirection to its argument. So if I write: AddIndirection( X ) The macro AddIndirection will do: #define X (*X) so after that point whenever you use X it gets replaced by (*X)
2
11362
by: marceliogp | last post by:
I have a file.h that have all my definitions and I need to define a array to use in my software, but I don´t know how can I do it. My define´s that cause error: .... #define ERROR_SAMPLE1 123 #define ERROR_SAMPLE2 124 .... #define FUNCTIONS_EMP { 20, 15, 22, 53, 34)
10
5472
by: Zhou Yan | last post by:
I want to define a pointer to a multiple-subscripted array. For instance, I have an array defined as below( I have reduced the size of the array as well as the dimension, but I think it OK to ask this simple case.) /---- int array = { 1, 2, 3, 4 } \-----
23
3932
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
5
1859
by: suresh | last post by:
Hi, How to define a two dimensional array where each row is of type vector<map<string,int>>? My idea is, if "x" is such a variable, x is a vector where each cell of the vector is a map<string,int>. Similarly x is a vector where each cell of it is a map<string,int>.
5
3473
by: maker.rain1 | last post by:
Hello All, I have come across a problem as explained below in a sample. Please help me if anyone has any ideas to solve this. I have a #define as defined below. #define MAX 200 int _tmain(int argc, _TCHAR* argv)
0
9893
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11001
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10664
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10722
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10348
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5919
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4137
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.