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

Tip: Looking for answers? Try searching our database.

Best way of designing Win Forms Call backs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 29 Aug 2007 12:06 GMT
I have a .Net 2 WinForm app which allow multi-windows to co-exist (in task
bar).  They are all spawned from a main-form.

(i.e., Form A can start Forms B,C,D,E)

2 questions about call-backs

Question 1) Forms B,C,D contains DataGridView, which I need to make sortable
on multiple columns/fields (which is not a built in .Net functionality, I
believe).  I need a new Modal dialog to be spawned from Forms B,C,D to allow
users to select sort fields and orders and then on closing the dialog, the
gridView in Forms B,C,D need to be refreshed with the new sort order selected
in the modal dialog.

What is the best way (of doing call-backs) from modal-Dialog X back to Forms
B,C,D?

Should I have
1) "Abstract" class MyDataGridForm with an abstract method called
ReSortGridView()
2) Have Forms B, C, D inherit from this abstract Form MyDataGridForm?
3) Define the Modal Sort selection dialog's constructor as taking in
MyDataGridForm as a parameter?

Any better ways of doing this?

Question 2) Ideally, it would be nice that for every new Form spawned off, a
"Window" navigation menuitem is added.  So each form would need a "handle" on
to all forms spawned.  What is the best way of doing this?
Collin - 29 Aug 2007 18:12 GMT
First I would post your question in two different post.

I can only give advice to the first question.  Use should use a
Behavioral Pattern like Mediator Pattern.  Create a global mediator
object (FormLeader) that has events.  When a Form A starts the
childrens is register it with the FormLeader object so the children
can talk and listen for events.  When someone clicks on data grid in a
child, it notify the FormLeader of that action.  The FormLeader takes
care of creating the ReOrder Dialog.  When the ReOrder dialog is
closed the FormLeader raise an event to notify anyone that is
listening that a re-order has occured.

<http://en.wikipedia.org/wiki/Mediator_pattern>
<http://www.dofactory.com/Patterns/PatternMediator.aspx>

I hope this put you on the right track.
> I have a .Net 2 WinForm app which allow multi-windows to co-exist (in task
> bar).  They are all spawned from a main-form.
[quoted text clipped - 25 lines]
> "Window" navigation menuitem is added.  So each form would need a "handle" on
> to all forms spawned.  What is the best way of doing this?
Marius Horak - 30 Aug 2007 09:11 GMT
> I can only give advice to the first question.  Use should use a
> Behavioral Pattern like Mediator Pattern.  Create a global mediator
[quoted text clipped - 5 lines]
> closed the FormLeader raise an event to notify anyone that is
> listening that a re-order has occured.

OMG!!! I need a master degree to understand this.
Hold on!!! I have a master degree in computing!!!

What's wrong with having somthing simple? Property or parameter will do.

MH
Marius Horak - 30 Aug 2007 09:09 GMT
> 3) Define the Modal Sort selection dialog's constructor as taking in
> MyDataGridForm as a parameter?

YES. KEEP IT SIMPLE!!!!
Even better you can use the grid as a parameter (or property).

> Question 2) Ideally, it would be nice that for every new Form spawned
> off, a "Window" navigation menuitem is added.  So each form would
> need a "handle" on to all forms spawned.  What is the best way of
> doing this?

ArrayList

MH

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.