473,426 Members | 1,754 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,426 software developers and data experts.

vb.net forms application

I'm writing a vb.net forms application. I collect some information
in a listbox from the main form. Then I want to use that listbox
arraylist in another form on the same application. What's the
best way to get that information or listbox object to the next form.

After a submit button click I want to go to
newform.DefInstance.ShowDialog() and I want the listbox to be
available, in scope.

Much Thanks;

Segue
Nov 23 '05 #1
12 1294
Hi, you can use a property for that:
for example on the second form where you want to show the items, you add a
property:

Public Property myItems() As ListBox.ObjectCollection
Get
Return ListBox1.Items
End Get
Set(ByVal Value As ListBox.ObjectCollection)
ListBox1.Items.AddRange(Value)
End Set
End Property

and on the first form where you call the second form you do something like
this:

Dim frm2 As New Form2
frm2.myItems = ListBox1.Items
frm2.Show()

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"segue" <se***@discussions.microsoft.com> schreef in bericht
news:2D**********************************@microsof t.com...
I'm writing a vb.net forms application. I collect some information
in a listbox from the main form. Then I want to use that listbox
arraylist in another form on the same application. What's the
best way to get that information or listbox object to the next form.

After a submit button click I want to go to
newform.DefInstance.ShowDialog() and I want the listbox to be
available, in scope.

Much Thanks;

Segue

Nov 23 '05 #2
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor
Nov 23 '05 #3
I ended up using this solution.

Thank You.

Regards;

Segue

"Peter Proost" wrote:
Hi, you can use a property for that:
for example on the second form where you want to show the items, you add a
property:

Public Property myItems() As ListBox.ObjectCollection
Get
Return ListBox1.Items
End Get
Set(ByVal Value As ListBox.ObjectCollection)
ListBox1.Items.AddRange(Value)
End Set
End Property

and on the first form where you call the second form you do something like
this:

Dim frm2 As New Form2
frm2.myItems = ListBox1.Items
frm2.Show()

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"segue" <se***@discussions.microsoft.com> schreef in bericht
news:2D**********************************@microsof t.com...
I'm writing a vb.net forms application. I collect some information
in a listbox from the main form. Then I want to use that listbox
arraylist in another form on the same application. What's the
best way to get that information or listbox object to the next form.

After a submit button click I want to go to
newform.DefInstance.ShowDialog() and I want the listbox to be
available, in scope.

Much Thanks;

Segue


Nov 23 '05 #4
Thanks for the response.

Cheers;

Segue

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor

Nov 23 '05 #5
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor

Nov 23 '05 #6
Hi it works just the same, but you need to use the item.addrange method:

Public Property myItems() As CheckedListBox.ObjectCollection
Get
Return CheckedListBox1.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
CheckedListBox1.Items.AddRange(Value)
End Set
End Property

Dim frm2 As New Form2
frm2.myItems = CheckedListBox1.Items
frm2.Show()

hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"segue" <se***@discussions.microsoft.com> schreef in bericht
news:44**********************************@microsof t.com...
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor

Nov 23 '05 #7
Seque,

Any reason you won't use the simple sample I showed you, you were talking
about a showdialog form.

For that is in my idea a property a typing overkill.

What I did not write, that you can set in top of your dialogform

Friend HisArraylist as arraylist

If that is not yet there.

Is in my opininon is that more than enough for that.

However just mine opinion.

Cor
"segue" <se***@discussions.microsoft.com> schreef in bericht
news:44**********************************@microsof t.com...
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor

Nov 23 '05 #8
Hi Segue I would also use Cor's example, because you're using a showdialog.
I overlooked that.

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:#5**************@TK2MSFTNGP09.phx.gbl...
Seque,

Any reason you won't use the simple sample I showed you, you were talking
about a showdialog form.

For that is in my idea a property a typing overkill.

What I did not write, that you can set in top of your dialogform

Friend HisArraylist as arraylist

If that is not yet there.

Is in my opininon is that more than enough for that.

However just mine opinion.

Cor
"segue" <se***@discussions.microsoft.com> schreef in bericht
news:44**********************************@microsof t.com...
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor


Nov 23 '05 #9

I could have cared less about the dialogue box.

Anyway this works if you're going from the main form to the 2nd form.

But how do you get the values from the 2nd form back to the main form.

Maybe I'm dense.

"Peter Proost" wrote:
Hi Segue I would also use Cor's example, because you're using a showdialog.
I overlooked that.

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:#5**************@TK2MSFTNGP09.phx.gbl...
Seque,

Any reason you won't use the simple sample I showed you, you were talking
about a showdialog form.

For that is in my idea a property a typing overkill.

What I did not write, that you can set in top of your dialogform

Friend HisArraylist as arraylist

If that is not yet there.

Is in my opininon is that more than enough for that.

However just mine opinion.

Cor
"segue" <se***@discussions.microsoft.com> schreef in bericht
news:44**********************************@microsof t.com...
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:

> Seque,
>
> You have only one form active in a time.
> Passing to a showdialog form is commonly done as
>
> \\\
> dim frm2 as new form2
> dim frm2.HisArraylist = myarraylist
> frm2.showdialog
> frm2.dispose
> ///
>
> I hope this helps,
>
> Cor
>
>
>



Nov 23 '05 #10
I could have cared less about the dialogue box.

Anyway this works if you're going from the main form to the 2nd form.

But how do you get the values from the 2nd form back to the main form.

Maybe I'm dense.

"Cor Ligthert [MVP]" wrote:
Seque,

Any reason you won't use the simple sample I showed you, you were talking
about a showdialog form.

For that is in my idea a property a typing overkill.

What I did not write, that you can set in top of your dialogform

Friend HisArraylist as arraylist

If that is not yet there.

Is in my opininon is that more than enough for that.

However just mine opinion.

Cor
"segue" <se***@discussions.microsoft.com> schreef in bericht
news:44**********************************@microsof t.com...
I couldn't figure out how to return the following though.
So I pre-empted the checkeditems and added them to
a normal listbox collection.

Public Property frmappnames() As CheckedListBox.ObjectCollection
Get
Return cmbflds2.Items
End Get
Set(ByVal Value As CheckedListBox.ObjectCollection)
cmbflds2.Items.Add(Value)
End Set
End Property

"Cor Ligthert [MVP]" wrote:
Seque,

You have only one form active in a time.
Passing to a showdialog form is commonly done as

\\\
dim frm2 as new form2
dim frm2.HisArraylist = myarraylist
frm2.showdialog
frm2.dispose
///

I hope this helps,

Cor


Nov 23 '05 #11
Segue,

In this sample you don't have to set anything back.

The arraylist is not transported, its address is transported.

I hope this helps,

Cor
Nov 23 '05 #12
Hmmm thnx for responding however, the order of the arraylist
is the same as it was before? I've tried quite a few things.
There must be something I'm not getting.

"Cor Ligthert [MVP]" wrote:
Segue,

In this sample you don't have to set anything back.

The arraylist is not transported, its address is transported.

I hope this helps,

Cor

Nov 23 '05 #13

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

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
9
by: Terrance | last post by:
Good Afternoon: I was hoping if someone could share some light on a problem that I'm facing. When I create a Visual Basic.Net program and I use the XP style for my Window Forms and buttons; if I...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
3
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
6
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
20
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in...
22
by: Jordan S. | last post by:
SQL Server will be used as the back-end database to a non trivial client application. In question is the choice of client application: I need to be able to speak intelligently about when one...
4
by: Mo | last post by:
Hi, I am writing a console application to send a key sequence to an old clunky application on a regular interval using the windows scheduler. I can get it to work if it is a windows form...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.