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

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.ParentForm

If Not frmParent.IsInsert Then 'SYNTAX ERROR line

Dim ctl As Control

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

Call FrameButtonPaintFlat(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 1451
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.Resources,
just Project1.

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

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

"Dean Slindee" <sl*****@charter.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.ParentForm

If Not frmParent.IsInsert Then 'SYNTAX ERROR line

Dim ctl As Control

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

Call FrameButtonPaintFlat(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*****@charter.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*****@charter.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.ParentForm

If Not frmParent.IsInsert Then 'SYNTAX ERROR line

Dim ctl As Control

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

Call FrameButtonPaintFlat(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*************@TK2MSFTNGP03.phx.gbl...
"Dean Slindee" <sl*****@charter.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**************@TK2MSFTNGP04.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****************@TK2MSFTNGP03.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
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...
2
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...
10
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...
1
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...
5
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
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. ...
1
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
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...
16
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...
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: 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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
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...

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.