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

Accessing one Form from Another

I am going crazy. Trying to create a secondary form, do a .DrawToBitmap of
the WebBrowser on it and send the bitmap to a PictureBox on the first form.

My problem is I cannot seem to create a method on form2 that I can access on
form1.

I tried using the advice from this link:

http://stackoverflow.com/questions/8...ther-form-in-c

I added this property code to form2:

public boolean ControlIsVisible
{
get { return control.Visible; }
set { control.Visible = value; }
}

Just to see if I could access it from form1, no go.

What am I doing wrong? Please Help!

Eric B.

Nov 15 '08 #1
8 1397
On 15/11/2008 in message
<AC**********************************@microsoft.co mEric B. wrote:
>What am I doing wrong? Please Help!
Are you creating an instance of Form2 from within Form1? e.g.:

Form2 frm2 = new Form2();

if so frm2.ControlIsVisible should work. If they are completely
independent forms it will be rather more complex.

--
Jeff Gaines Damerham Hampshire UK
The facts, although interesting, are irrelevant
Nov 15 '08 #2
You need to post the code that creates form2 and then tries to access this
property.

My bet is that you are doing this

Form form2 = new Form2();

rather than this

Form2 form2 = new Form2();

--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

Nov 15 '08 #3
"Peter Morris" <mr*********@SPAMgmail.comwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
You need to post the code that creates form2 and then tries to access this
property.

My bet is that you are doing this

Form form2 = new Form2();

rather than this

Form2 form2 = new Form2();

--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

Yes! I see now. I was in effect creating an instance of Form instead of
Form2, right?

Thank you so much!

Eric B.

Nov 15 '08 #4
On Sat, 15 Nov 2008 06:36:18 -0800, Eric B. <bi*****@sesamestreet.com>
wrote:
>My bet is that you are doing this

Form form2 = new Form2();

rather than this

Form2 form2 = new Form2();


Yes! I see now. I was in effect creating an instance of Form instead of
Form2, right?
No. Assuming Pete M.'s guess about your code was correct (note that since
you still haven't bothered to post any code, all we can do is
guess...that's not a very good way for you to get actual answers to your
question), then you did in fact create an instance of Form2. But you
assigned it to a variable that is typed as Form, and with that variable
you can only access things in the Form class.

Pete
Nov 15 '08 #5
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sat, 15 Nov 2008 06:36:18 -0800, Eric B. <bi*****@sesamestreet.com>
wrote:
>>My bet is that you are doing this

Form form2 = new Form2();

rather than this

Form2 form2 = new Form2();


Yes! I see now. I was in effect creating an instance of Form instead of
Form2, right?

No. Assuming Pete M.'s guess about your code was correct (note that since
you still haven't bothered to post any code, all we can do is
guess...that's not a very good way for you to get actual answers to your
question), then you did in fact create an instance of Form2. But you
assigned it to a variable that is typed as Form, and with that variable
you can only access things in the Form class.

1) We can assume his assumption was correct because it solved my problem.
Usually when a problem is solved by a given solution we consider the
solution was in fact correct.

2) I did post some code, perhaps you need glasses as well?

3) There was no need to further post code because as I suspected my problem
was able to be solved by describing the circumstances involved. It was a
newbie mistake, that's all.

4) Your explanation appears to just be a long-winded way of saying the same
thing I did, that I *in effect* created an instance of Form instead of a
Form2.

Eric B.

Nov 16 '08 #6
On Sun, 16 Nov 2008 06:17:06 -0800, Eric B. <bi*****@sesamestreet.com>
wrote:
1) We can assume his assumption was correct because it solved my
problem. Usually when a problem is solved by a given solution we
consider the solution was in fact correct.
You never stated that it actually solved your problem. There was no way
for anyone to make that inference.
2) I did post some code, perhaps you need glasses as well?
Sorry, I should have been more specific: "you still haven't bothered to
post any of the _relevant_ code". That is, you complained that something
didn't work, but you didn't show any of the code actually trying to use
what didn't work.

Yes, you posted code. But the code you posted had nothing to do with your
problem.
3) There was no need to further post code because as I suspected my
problem was able to be solved by describing the circumstances involved.
It was a newbie mistake, that's all.
You never posted relevant code in the first place. It's great that Pete's
advice helped you, but a) you never said that it had solved your problem,
and b) whether it helped you or not, the fact is that it is still
impossible to make any definitive statements about your code, since we
haven't seen it.
4) Your explanation appears to just be a long-winded way of saying the
same thing I did, that I *in effect* created an instance of Form instead
of a Form2.
No, absolutely, incontrovertibly not. You are repeating the same
erroneous statement that you made previously, and to which I replied
pointing out its error, and that is certainly not a correct summarization
of my post.

Again, since you haven't posted the code, I cannot state definitively what
_your_ code is or is not doing. But, if we assume it looks the same as
the "Form form = new Form2()" that Pete guessed, you are NOT creating an
instance of Form. That is, the actual type of the instance isn't Form
(though it certainly inherits Form).

Just because the type of the variable holding the reference is Form, that
doesn't mean that the instance itself is of the type Form.

If you are new to object-oriented programming, it's not surprising that
this might be a confusing aspect for you, nor should it be a point of
embarassment if you're not quite getting it yet. These things take time
to learn.

But acting out in the belligerent way that you're doing now isn't a very
good way to learn. All it does is put yourself in a state of mind where
it's very difficult for you to learn the unfamiliar concepts that are
giving you trouble in the first place, and to make people less inclined to
try to help you in the future.

Pete
Nov 16 '08 #7
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sun, 16 Nov 2008 06:17:06 -0800, Eric B. <bi*****@sesamestreet.com>
wrote:
>1) We can assume his assumption was correct because it solved my
problem. Usually when a problem is solved by a given solution we
consider the solution was in fact correct.

You never stated that it actually solved your problem. There was no way
for anyone to make that inference.
I suppose "Yes! I see it now!" was far too subtle for you. :/
>2) I did post some code, perhaps you need glasses as well?

Sorry, I should have been more specific: "you still haven't bothered to
post any of the _relevant_ code". That is, you complained that something
didn't work, but you didn't show any of the code actually trying to use
what didn't work.

Yes, you posted code. But the code you posted had nothing to do with your
problem.
The code I posted *was* the code that didn't work. Are you pretending to be
this thick?

Eric B.

Nov 17 '08 #8
On Mon, 17 Nov 2008 07:41:16 -0800, Eric B. <bi*****@sesamestreet.com>
wrote:
>You never stated that it actually solved your problem. There was no
way for anyone to make that inference.

I suppose "Yes! I see it now!" was far too subtle for you. :/
Yes, especially since you followed it with a statement that showed clearly
that you did NOT in fact "see it now".
[...]
>Yes, you posted code. But the code you posted had nothing to do with
your problem.

The code I posted *was* the code that didn't work. Are you pretending to
be this thick?
Here is the only code you've posted to this thread:

public boolean ControlIsVisible
{
get { return control.Visible; }
set { control.Visible = value; }
}

Assuming you were telling the truth when you indicated that the code Pete
M. posted helped you, then that's not the code that wasn't working.
Nothing in your message suggested that the above code failed to compile.

Based on the vague description you offered -- "I added this property code
to form2 [...] Just to see if I could access it from form1, no go." -- the
code that wasn't working was some line of code that you haven't posted
yet, in which you actually tried to use the property you declared but
failed (i.e. "no go").

As far as being "thick" goes, my fear is that you are _not_ pretending.
But, as I pointed out, your belligerence will hurt only yourself. If
that's your preferred approach, suit yourself. But you aren't going to
learn anything that way.

Pete
Nov 17 '08 #9

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

Similar topics

3
by: Tom Meuzelaar | last post by:
Hello: I'm using VB6 in VS enterprise. I'd like to place an HTML form inside a VB container, have a user fill out the form information, click a submit button, and then have the program capture...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
8
by: Mike Caputo | last post by:
In VB.NET, need to be able to access certain properties on my main form from other forms. These are properties that may be changed by the user, so I have to be able to get to them throughout the...
1
by: tmaster | last post by:
Within a class, can I create a property that is a listview? Here's what I tried, but it doesn't seem to work: '------------ create property to give the second form access to the first form's...
9
by: Blake Weaver | last post by:
Ok, this is probably a no-brainer for most of you but its escaping me and I can't even seem to find the answer in any documentation. How do you access a friend variable of one class, from another...
3
by: Tim Fitzgerald | last post by:
Hello all, I have no problem accessing another form in my app.. however, when I try to access a ListView on a different form, I come up empty... Basically, Dim pForm As New frmMain Dim iCount...
0
by: Geraldine Hobley | last post by:
Hello I have a problem whereby I have a treeview control on one form called projecttree and I wish to clea the nodes from this control in another form The form that contains the treeview is...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
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...

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.