Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / May 2006

Tip: Looking for answers? Try searching our database.

Addins - how to use data members of Connect class from a form invoked from it

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
datamodel - 21 May 2006 13:55 GMT
Hello,

I have an Addin project. Which has a Connect class.
At some point in Connect.OnConnection() a form is spawned to capture
some user input.
Before the form close, I would like to send that input back to one of
Connect's public strings,
eg, inside the form class's submit button handler,

Connect.str_user_input = txtInput.Text;

However I get a build error for this :
"An object reference is required for the nonstatic field, method, or
property MyAddinProject.Connect.str_user_input"

How do I achieve what I'd like to do? how to work around this error? Is
what I want feasible or not? Thanks a lot in advance.

Data.
Peter Macej - 22 May 2006 09:31 GMT
> "An object reference is required for the nonstatic field, method, or
> property MyAddinProject.Connect.str_user_input"

You are trying to set str_user_input variable via class name Connect and
not particular Connect instance. You can do this only if str_user_input
is defined as static (Shared in VB). So you can:
1. In Connect, define str_user_input with "static" keyword. Not the best
approach.
2. Create public or internal property userInput in your form. Set its
value in the button handler:
this.userInput = txtInput.Text;

Then you can easily read myForm.userInput from Connect class if myForm
is an instance (not class name) of your form.

Signature

Peter Macej
Helixoft - http://www.vbdocman.com
VBdocman - Automatic generator of technical documentation for VB, VB
.NET and ASP .NET code

datamodel - 22 May 2006 12:52 GMT
Thanks a lot for the reply. This is good advice for this issue.

I've also resolved the issue using another method. I defined a an event
handler class, and a delegate for its args, and made the form to send
that event to be handled by Connect.
More complicated - so your solution remains the simpler route.

Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.