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 / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

How to reflect inputs of one form to another?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
paradox81 - 25 Jul 2006 15:00 GMT
Hi all,

i am currently writing a small application which involves two forms. Form A
is used primarily for display purposes while form B is used to gather user
input via a number of textboxes and numeric updowns.

The situation now is that when the user keys in his/her input to form B and
clicks a "add" button, i need to reflect the new inputs on form A. What i
have done now is to start a new thread on form A to wait for changes to take
place on form B. When user clicks the "add" button, a boolean variable
changes to true and the thread spawned from form A attempts to read the value
and reflect it on a Listview control on form A.

However, the problem i face now is that i get an exception which states that
i am not allowed to access members from another thread, meaning the thread
spawned from form A is not allowed to access the listview control on form A.

Is there anything i can do to go around this problem, or is there any other
methods i can use to reflect inputs from form B on form A.

I am using visual c# by the way... Thanks for any help in advance.
Dave Sexton - 25 Jul 2006 20:19 GMT
Hi paradox81,

You must call ListView.Invoke from your background thread to marshal the call to the UI thread.

delegate void UpdateListViewInternalInvoker(object data);

public void HandleDataChanged(object data)
{
   myListView.Invoke(new UpdateListViewInternalInvoker(UpdateListView), data);
}

private void UpdateListViewInternal(object data)
{
   // TODO: update ListView
}

Signature

Dave Sexton

> Hi all,
>
[quoted text clipped - 17 lines]
>
> I am using visual c# by the way... Thanks for any help in advance.

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.