473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get a form's property value from a class?

I have a form whose Property value I need to get at from a class (contained
in another project, same solution).

Here is the form's property:

Private booIsInsert As Boolean = False

Public Property IsInsert() As Boolean

Get

Return booIsInsert

End Get

Set(ByVal Value As Boolean)

booIsInsert = Value

End Set

End Property

Here is the class's function that needs the property value:

Public Shared Sub FormDataChanged (ByVal sender As System.Object)

Dim frmParent As Form

frmParent = sender.ParentFo rm

If Not frmParent.IsIns ert Then 'SYNTAX ERROR line

Dim ctl As Control

ctl = CType(frmParent .Controls.Item( "btnUpdate" ), Control)

Call FrameButtonPain tFlat(frmParent , CType(ctl, Control)) 'green
frame around button

End If

Syntax error message: "IsInsert is not a member of
System.Windows. Forms.Form"

I understand the error, but is there *any* way to reference the frmParent
instance and get the IsInsert property value?

Or some other approach?

Thanks in advance.

Dean S


Nov 22 '06 #1
8 1465
You probably need to add a reference to
the project containing the class in which
you want to access that form's property.
(Did you get that?)

To be clearer (I hope), an example:

1) Project 1, has Form1 with property IsInsert.
2) Project 2, has Class1 that wants to access
Form1's property IsInsert.

Open Project2's properties and click on References.
THen click on Add. Choose the Projects tab, and
select Project1.

Then on the bottom of the screen, where it has
Imported Namespaces, find Project1 in the list
and check it (you'll have to click it twice).
Not Project1.My or Project1.My.Res ources,
just Project1.

*Now* you should be able to access Form1.IsInsert.

Good luck.
Robin S.
----------------------------------------

"Dean Slindee" <sl*****@charte r.netwrote in message
news:2a******** ******@newsfe06 .lga...
>I have a form whose Property value I need to get at from a class (contained
in another project, same solution).

Here is the form's property:

Private booIsInsert As Boolean = False

Public Property IsInsert() As Boolean

Get

Return booIsInsert

End Get

Set(ByVal Value As Boolean)

booIsInsert = Value

End Set

End Property

Here is the class's function that needs the property value:

Public Shared Sub FormDataChanged (ByVal sender As System.Object)

Dim frmParent As Form

frmParent = sender.ParentFo rm

If Not frmParent.IsIns ert Then 'SYNTAX ERROR line

Dim ctl As Control

ctl = CType(frmParent .Controls.Item( "btnUpdate" ), Control)

Call FrameButtonPain tFlat(frmParent , CType(ctl, Control)) 'green
frame around button

End If

Syntax error message: "IsInsert is not a member of
System.Windows. Forms.Form"

I understand the error, but is there *any* way to reference the frmParent
instance and get the IsInsert property value?

Or some other approach?

Thanks in advance.

Dean S


Nov 22 '06 #2
"Dean Slindee" <sl*****@charte r.netwrote in message
news:2a******** ******@newsfe06 .lga...
>I have a form whose Property value I need to get at from a class (contained
in another project, same solution).
I'd suggest you're doing something wrong. In all my years of programming I
don't think I've ever done this or needed to do this. The form should pass
whatever information it needs to the class so the class can perform its
task. Can you explain more what you're doing?

If you really need to do this I'm presuming Robin's answer won't help
because the project with the form already has a reference to the project
with the class, so you can reference the other way. But what you can do is
define an interface in the project with the class and have the form
implement that interface.

Michael
Nov 22 '06 #3
Dean,

I have almost the same idea as Michael, even more, it seems that you want to
give the property at a certain moment to the class. I think that than a
method is more sufficient because than the given data can be processed.

Cor

"Dean Slindee" <sl*****@charte r.netschreef in bericht
news:2a******** ******@newsfe06 .lga...
>I have a form whose Property value I need to get at from a class (contained
in another project, same solution).

Here is the form's property:

Private booIsInsert As Boolean = False

Public Property IsInsert() As Boolean

Get

Return booIsInsert

End Get

Set(ByVal Value As Boolean)

booIsInsert = Value

End Set

End Property

Here is the class's function that needs the property value:

Public Shared Sub FormDataChanged (ByVal sender As System.Object)

Dim frmParent As Form

frmParent = sender.ParentFo rm

If Not frmParent.IsIns ert Then 'SYNTAX ERROR line

Dim ctl As Control

ctl = CType(frmParent .Controls.Item( "btnUpdate" ), Control)

Call FrameButtonPain tFlat(frmParent , CType(ctl, Control)) 'green
frame around button

End If

Syntax error message: "IsInsert is not a member of
System.Windows. Forms.Form"

I understand the error, but is there *any* way to reference the frmParent
instance and get the IsInsert property value?

Or some other approach?

Thanks in advance.

Dean S


Nov 22 '06 #4
If you want project1 to reference something in project2,
you must add a reference to project1, even if project2
has a reference to project1. It's project-specific, and
project1 doesn't know about project2's reference to project1.
Did I use the word project in there enough times? ;-)

Robin S.
--------------------
"Michael C" <no****@nospam. comwrote in message
news:eE******** *****@TK2MSFTNG P03.phx.gbl...
"Dean Slindee" <sl*****@charte r.netwrote in message
news:2a******** ******@newsfe06 .lga...
>>I have a form whose Property value I need to get at from a class
(contained in another project, same solution).

I'd suggest you're doing something wrong. In all my years of programming I
don't think I've ever done this or needed to do this. The form should pass
whatever information it needs to the class so the class can perform its
task. Can you explain more what you're doing?

If you really need to do this I'm presuming Robin's answer won't help
because the project with the form already has a reference to the project
with the class, so you can reference the other way. But what you can do is
define an interface in the project with the class and have the form
implement that interface.

Michael

Nov 22 '06 #5
"RobinS" <Ro****@NoSpam. yah.nonewrote in message
news:AL******** *************** *******@comcast .com...
If you want project1 to reference something in project2,
you must add a reference to project1, even if project2
has a reference to project1. It's project-specific, and
project1 doesn't know about project2's reference to project1.
Did I use the word project in there enough times? ;-)
For a start you can't add a reference to an exe project. Even if both
projects were dlls I doubt you could add a circular reference. Even if you
could this would be bad practice. Which would you compile first?

Michael
Nov 26 '06 #6
I assumed he was talking about having multiple project
inside one solution. If I misunderstood, then never mind. :-)

Robin S.
----------------------------------
"Michael C" <no****@nospam. comwrote in message
news:ub******** ******@TK2MSFTN GP04.phx.gbl...
"RobinS" <Ro****@NoSpam. yah.nonewrote in message
news:AL******** *************** *******@comcast .com...
>If you want project1 to reference something in project2,
you must add a reference to project1, even if project2
has a reference to project1. It's project-specific, and
project1 doesn't know about project2's reference to project1.
Did I use the word project in there enough times? ;-)

For a start you can't add a reference to an exe project. Even if both
projects were dlls I doubt you could add a circular reference. Even if you
could this would be bad practice. Which would you compile first?

Michael

Nov 26 '06 #7
"RobinS" <Ro****@NoSpam. yah.nonewrote in message
news:XL******** *************** *******@comcast .com...
>I assumed he was talking about having multiple project
inside one solution. If I misunderstood, then never mind. :-)
He was. For projects in the same solution I doubt you can add a circular
reference.

Michael
Nov 26 '06 #8

"Michael C" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
"RobinS" <Ro****@NoSpam. yah.nonewrote in message
news:XL******** *************** *******@comcast .com...
>>I assumed he was talking about having multiple project
inside one solution. If I misunderstood, then never mind. :-)

He was. For projects in the same solution I doubt you can add a circular
reference.

Michael
Yes, you're absolutely right. I must have had some temporary
insanity going on there, to think that would work. My mistake.
Thanks for clarifying.

Robin S.
Nov 27 '06 #9

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

Similar topics

1
4196
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens in IE as well as FireFox. This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL 4.1.8 and it works fine. The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.
2
2800
by: Yasutaka Ito | last post by:
Hi folks! I have a BaseForm class that inherits System.Windows.Forms.Form. It has a property, whose value I need supplied by the class that inherits it. The BaseForm usees the value supplied into this property in its Load event. So, I gave the BaseForm and the property 'abstract' modifier, and put the implementation of the property in the inherited class; say MyForm. However, when I did this, I no longer can open MyForm in the design...
10
19361
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
1
2397
by: kyma via .NET 247 | last post by:
Hi, I haveto use VB to create a form that reads an exisiting XML fileand then allows updates via the VB form. My problem is that I was able to get VB to read a simple XML file(people.XML), but I'm having problems figuring out how to get VBto read a more complex XML file (people2.xml) and then useadditional text boxes on the same form to add more familymembers. Each family can have from 1 to 5 members. I've pasted the working code below...
5
73215
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
4
2447
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. The first class handles the form generation - (this was done using GUI form designer).
1
1549
by: steven scaife | last post by:
Hi I have created a class that inherits from dictionarybase code below. Public Class FrmLabels Inherits Label Private m_Lbl As Label Public Property lbl() As Label Get Return m_Lbl End Get
12
2371
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1 from the User Control in Form2 ? Hope this is clear enough...
16
4174
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and therefore being able to modify its properties?
0
9641
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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

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.