By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

How to access a control in another form

P: n/a
In VB6 I was able to accessa control like a progressbar form a different
form, for example

frm1.progressbar1.value =XXX

but now how can I do that in VB.NET

Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Create a public property on the second form that references the control
value - then you can juse reference it as Form2.WhateverProperty

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Carlos" <cp@swa.com> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
In VB6 I was able to accessa control like a progressbar form a different
form, for example

frm1.progressbar1.value =XXX

but now how can I do that in VB.NET

Thanks

Nov 20 '05 #2

P: n/a
Excuse my ignorance,
how can you do that ?

Thanks
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
Create a public property on the second form that references the control
value - then you can juse reference it as Form2.WhateverProperty

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Carlos" <cp@swa.com> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
In VB6 I was able to accessa control like a progressbar form a different
form, for example

frm1.progressbar1.value =XXX

but now how can I do that in VB.NET

Thanks


Nov 20 '05 #3

P: n/a
a
There is not an 'automatic form collection' in VB.NET.

If the Progress Bar is on Form1, then when you open Form2, it needs to have
a way of finding the Open version of Form1. Just referring to Form1 does
not get a reference to the Open Form1, just to the Form1 class. (You could
have 20 open Form1's in your app)

So, Form2 would have a variable that refers to the open Form1:

Public frmWithProgressBar as Form1
Then to open Form2, Form1 would do:

Dim f as new Form2
f.frmWithProgressBar = Me
f.show
Then Form2 would reference the ProgressBar on the Form1 that opened it as:

me.frmWithProgressBar.NameOfTheProgressBarOnForm1

You could do a property on Form2, but the Public Variable is easier to begin
with.

Kevin
"Carlos" <cp@swa.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Excuse my ignorance,
how can you do that ?

Thanks
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
Create a public property on the second form that references the control
value - then you can juse reference it as Form2.WhateverProperty

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Carlos" <cp@swa.com> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
In VB6 I was able to accessa control like a progressbar form a different form, for example

frm1.progressbar1.value =XXX

but now how can I do that in VB.NET

Thanks



Nov 20 '05 #4

P: n/a
* "Carlos" <cp@swa.com> scripsit:
In VB6 I was able to accessa control like a progressbar form a different
form, for example

frm1.progressbar1.value =XXX


If 'frm1' is the app's main form, then you can use the approach
described here:

<URL:http://dotnet.mvps.org/dotnet/faqs/downloads/accessmainform.txt>

If the 2nd form is a dialog that is shown from within the main form or
the form containing the progressbar, add a property to the 2nd form and
assign the progressbar to it after instantiating the 2nd form. Then you
will be able to access the progressbar from within the 2nd form.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.