Windows Forms Application

  • Thread starter Thread starter eXtreme
  • Start date Start date
E

eXtreme

How do I make a dataset available to all forms (including dialogs) in a
Windows Form based application?

Thanks,
eXtreme
 
I made the object Public and form it is on Public but a dialog spun from
that Form is not able to see it.

Where do I check the visibility?

Thanks,
 
You can either pass a reference to the form to the child form, so that it
can refer to the public members.

Alternative: you can provide a static method on the form that will return
the object. You do not need a reference to the object in the calling code
to call the static method. You can just use the name of the class. This is
a Singleton.

Take a look at http://www.pobox.com/~skeet/csharp/singleton.html


--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
What's the best book I can buy, which is C# based, and would teach me about
Windows Forms and how to reference objects not in the current form?

Thanks,
eXtreme
 
Hi eXtreme,

For winform books, I'd recommend Chris Cells's

#Windows Forms Programming in C#
http://www.amazon.com/exec/obidos/tg/detail/-/0321116208/102-9824083-4872945
?v=glance

Also, there're many good tech articles in MSDN

#Windows Forms Programming in C#
http://msdn.microsoft.com/library/en-us/dnanchor/html/WinFormsAnchor.asp?fra
me=true

In addition, as for the
===============
how to reference objects not in the current form?
===============
you mentioned, I think it depends on the objects/data's role and
functionality in your app. Is it usefule and accessiable from all the forms
in your app? If it's a global data, I think you can consider Nick 's
suggestion on using a singleton class which hold the goblal object
references so that we can Access those objects/datas from any form or
class's code. Since your scenario is winform(clientside app) , we don't
need to worry too much about cocurrecy issues.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top