473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Index


Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a unique index, how is done in vb.net? bellow is the code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Dim i As Integer =
Dim myPic(10) as pictureBo
Dim yAxis As Integer =
For i = 0 To

MyPic(i) = New PictureBo

MyPic(i).Width = 13
MyPic(i).Height = 4

'Mypic(i).Font = New Font("Verdana", 9.75!, FontStyle.Regular

MyPic(i).BackColor = Drawing.Color.Blac
MyPic(i).SizeMode = PictureBoxSizeMode.StretchImag
MyPic(i).Location = New System.Drawing.Point(Left, Top
MyPic(i).Name = "Pic" &
'Mypic(i).Text = rst("ProductName").Valu
MyPic(i).Location = New Point(660, yAxis
MyPic(i).Cursor = Cursors.Han
MyPic(i).BringToFront(
Me.Controls.Add(MyPic(i)
MyPic(i).Image = ImageList1.Images.Item(i

AddHandler MyPic(i).Click, AddressOf mypic_clic
yAxis = yAxis + 5 + MyPic(i).Heigh
Nex
End Su

NEED THE CODE PLEAS

THANX IN ADVANCE
Nov 20 '05 #1
17 1565
In article <2F**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...

Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button

had a unique index, how is done in vb.net?

1) Create a form-level ArrayList.
2) After creating the button, add it to the ArrayList at the specified
index. Example:

myList.Insert(i, myNewButton)

3) In the click event handler, the "sender" object will be the button
that was pushed. Use the "IndexOf" method to find out which button was
pushed:

Dim index As Integer = myList.IndexOf(sender)

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
* "=?Utf-8?B?V2lsbA==?=" <an*******@discussions.microsoft.com> scripsit:
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button
had a unique index, how is done in vb.net? bellow is the code:


Creating Control Arrays in Visual Basic .NET and Visual C# .NET
<http://msdn.microsoft.com/library/?url=/library/en-us/dv_vstechart/html/vbtchCreatingControlArraysInVisualBasicNETVisualCN ET.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
In article <5F**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...
Great example one question, could you please give me an example (code) on how to create a form-level ArrayList ?
thanx


Just define it outside of all of your methods:

Public Class MyForm
Inherits Form

Private myList As ArrayList = new ArrayList()

...
--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #4
Cor
Hi Will,

I do not understand this, this is almost the sample I gave you and the code
is VB.net code how did you do this in VB6?

Cor
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer = 0
Dim myPic(10) as pictureBox
Dim yAxis As Integer = 9
For i = 0 To 1
MyPic(i) = New PictureBox

MyPic(i).Width = 130
MyPic(i).Height = 40

'Mypic(i).Font = New Font("Verdana", 9.75!, FontStyle.Regular)

MyPic(i).BackColor = Drawing.Color.Black
MyPic(i).SizeMode = PictureBoxSizeMode.StretchImage
MyPic(i).Location = New System.Drawing.Point(Left, Top)
MyPic(i).Name = "Pic" & i
'Mypic(i).Text = rst("ProductName").Value
MyPic(i).Location = New Point(660, yAxis)
MyPic(i).Cursor = Cursors.Hand
MyPic(i).BringToFront()
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
yAxis = yAxis + 5 + MyPic(i).Height
Next
End Sub

NEED THE CODE PLEASE

THANX IN ADVANCE

Nov 20 '05 #5
Cor
Hi Herfried,

This is a message about a VB.net sample I gave can this be done in VB6?

Cor
Nov 20 '05 #6
Cor
Hi Patrick,

This is a message about a VB.net sample I gave, can this be done in VB6?

In my sample is no need for an Arraylist I use that almost always, except
when the array is fixed as is in this sample.

Cor
Nov 20 '05 #7
Cor
Hi Patrick,

This is the correct answer by the way, accoording to my sample, although it
is an array
Just define it outside of all of your methods:


But I did wanted to keep the sample nice and putted it inside the procedure.
Using directcast with the sender in the event, that I also supported (it is
disapeared now), it is not really needed, but when you do more with it, it
can be the answer.

And when the array really becomes dynamic using an arraylist is of course
better.

Cor
Nov 20 '05 #8
Cor,

* "Cor" <no*@non.com> scripsit:
This is a message about a VB.net sample I gave can this be done in VB6?


What? Sorry, I don't understand what you want to tell me...

:-(

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
Cor
Hi Herfried,

The poster tells that he has created this in VB6 while it is code I
supported to him on 26-1.
(You should have seen it before because I have contributed this so much,
because I find it a real nice example because it is so simple).

And now I am curious if this code can be done in VB6 because you are
answering that.

This is the start of the original thread
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a

unique index, how >is done in vb.net? bellow is the code:

I think that code cannot be done in VB6.

Or am I crazy?

Cor
Nov 20 '05 #10
Cor,

* "Cor" <no*@non.com> scripsit:
This is the start of the original thread
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a

unique index, how >is done in vb.net? bellow is the code:

I think that code cannot be done in VB6.


Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #11
Cor
Herfried,

Look at the code he said he made this in VB6.
Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?

Cor
Nov 20 '05 #12
Cor,

* "Cor" <no*@non.com> scripsit:
Look at the code he said he made this in VB6.
Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?


Yes, something similar was possible with VB6. You could create a
control array and create a common handler for the array. The shared
handler had an index parameter which contained the index of the control
in the control array firing the event.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #13
Cor
The OP stated that he has written this code with VB6 that is my question.
I believe that something simular was posible exactly this code on VB6
(knowing me you know of course that I tried it already before I wrote this,
but did I see something wrong?)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?


Yes, something similar was possible with VB6. You could create a
control array and create a common handler for the array. The shared
handler had an index parameter which contained the index of the control
in the control array firing the event.

Nov 20 '05 #14
* "Cor" <no*@non.com> scripsit:
The OP stated that he has written this code with VB6 that is my question.


Sorry, I misread. The code the OP posted won't run on VB6.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #15
Cor
No problem...

:-)

I could copy it,

:-))

Cor
Nov 20 '05 #16
Cor,

* "Cor" <no*@non.com> scripsit:
No problem...

:-)

I could copy it,


What?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #17
Cor
No proplem
What?


:-))
Nov 20 '05 #18

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

Similar topics

3
by: Jofio | last post by:
Hello, I am a newbie in PHP and I am enthusiastically trying out things. I've just replaced my index.html ( file with index.php
9
by: kosh | last post by:
I was wondering if there is or there could be some way to pass a generator an optional starting index so that if it supported that slicing could be made more efficient. Right now if you do use a...
2
by: skura | last post by:
I am trying to understand how the data in sql server is stored and also regarding fill factor and page splitting. 1) My first question what is the difference between Index pages and Data pages....
6
by: Anita | last post by:
I have just tested 3 queries using QA. The complete test information : ------ CREATE TABLE agls1 ( fyear char(4) NULL , fprefix char(3) NULL , fvcno char(20) NULL , fdate datetime NULL ,...
8
by: Andr? Queiroz | last post by:
Hi, I have a table with 10M records and col A has a index created on it. The data on that table has the same value for col A on all 10M records. After that I insert diferent values for that column...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
2
by: bobby_b_ | last post by:
I have a table where fields 1 and 2 make up the primary key. Because of this, I have a unique composite index on fields 1 and 2 (as required by DB2). Now my question is: Fields 1 and 2 are also...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
8
by: shira | last post by:
I have done a fair bit of searching, but haven't yet been able to find an explanation as to why one would set "ignore nulls" to "yes" when creating an index. I understand what it does (I think),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.