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 / February 2007

Tip: Looking for answers? Try searching our database.

User Controls Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nntp.microsoft.com - 23 Feb 2007 19:01 GMT
I have been struggling with this for too long now, an desperately need help.
I'm an asp.net programmer, but am working on a windows form for this app.  I
have 1 form and 2 user controls, Say UC(A) and UC(B).  UC(A) has a datagrid,
UC(B) has a ListBox.  When I click on the Datagridrow  in UC(A) , the
Listbox in UC(B) should Update based upon an ID in the Datagrid, but It
wont.  I have Tried using RaiseEvents first, then I tried just making a
Public Method, and then I tried a Public Property.  The code in UC(B) is
Fired properly, and the Dataset is retreived from my DataClass, but When I
tell my listbox what the data source is, it wont rebind or redraw or
something. I also tried the declaring a public event in UC(A), and then
Delare UC(A) in UC(B) and setting a method to handle it. But that does not
work  It fires the event, but nothing at all happens in UC(B).

What am I missing.

Tom Callahan
Bruce Wood - 26 Feb 2007 01:01 GMT
> I have been struggling with this for too long now, an desperately need help.
> I'm an asp.net programmer, but am working on a windows form for this app.  I
[quoted text clipped - 10 lines]
>
> What am I missing.

Well, you would need to post some code for us to see exactly what is
going wrong.

However, I would start by architecting the solution this way: UC(A)
declares a public event (which you did). UC(B) exposes a public get/
set property for the ID that it needs in order to show what it needs
to show. (If it needs more than an ID, such as say a row in a DataSet,
it could expose a property to accept the entire row.)

Then, in your enclosing form, subscribe to UC(A)'s event, and in the
event handling method get the ID (or whatever information) from UC(A)
via some public property that you define, and then use UC(B)'s public
property to set the info in UC(B). In other words, the enclosing form
acts as the go-between: it reacts to the event from UC(A) and then
feeds UC(B) whatever information it needs.

This way neither user control needs to know about the other. It's a
bit more code to write, but it's way easier to debug.

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.