11 Replies - 1435 Views - Last Post: 03 May 2011 - 09:24 AM Rate Topic: -----

#1 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Winforms application design

Posted 03 May 2011 - 05:24 AM

Hi

I need to make a Windows forms application in C#. I have done simple apps with one screen and a few buttons before.
But now i need to make an application that has one main form, and inside it there is a menu, and each menu item when opened displays a different container with labels and controls. There may be over 40 such containers.

Would you please tell me how to solve this problem or better, a tutorial or a book where I can learn about these design problems?

Thank you in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Winforms application design

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: Winforms application design

Posted 03 May 2011 - 07:06 AM

It sounds pretty straight forward. What's the problem?

Create a new winform project.
Create 0-n extra forms with your labels and controls.
In your main form add menu bar.
Add menu bar buttons
Double click on menu bar buttons to get their event to create.
In each event declare, initialize, and do a '.show' or '.show dialog' for the appropriate form you created in step 2.
Repeat.
Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,713
  • Joined: 08-June 10

Re: Winforms application design

Posted 03 May 2011 - 07:11 AM

I'm not sure I understand your problem. You've identified what you need to do, and you've done it on a small scale before. You just have to do it on a larger scale now.
Was This Post Helpful? 0
  • +
  • -

#4 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Winforms application design

Posted 03 May 2011 - 07:22 AM

This scenario is called MDI - multi document interface. You have a template in Visual studio and a tutorial here
Was This Post Helpful? 2
  • +
  • -

#5 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Re: Winforms application design

Posted 03 May 2011 - 07:30 AM

Maybe I should explain better.

When I click on a menu item i don't need to open another form but change what is displayed on the main working panel. For example let the current view be Create Person with all the textboxes for entering data about the person. When I click on View Persons on the menu, i need to display a Gridview on the main working panel in the place of the textboxes.
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,713
  • Joined: 08-June 10

Re: Winforms application design

Posted 03 May 2011 - 07:32 AM

Create UserControls, each with public properties to contain the data they'll need. Then you can create instances of these user controls in your main form, and add them to the form when necessary.
Was This Post Helpful? 2
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: Winforms application design

Posted 03 May 2011 - 07:36 AM

Soooooo some sort of tab view?
Was This Post Helpful? 0
  • +
  • -

#8 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Re: Winforms application design

Posted 03 May 2011 - 08:03 AM

Thanks for the replies guys.

I tried to make it with UserControls like Curtis Rutland said and it is working.

Best regards

This post has been edited by tashe: 03 May 2011 - 08:21 AM

Was This Post Helpful? 0
  • +
  • -

#9 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Winforms application design

Posted 03 May 2011 - 09:09 AM

Yep, user controls are one of the nicer ways I think. I've used them for many projects and they are easy enough to use.

I suggest using a Panel on the main form, and then dynamically loading the user control you need inside that Panel.
Was This Post Helpful? 0
  • +
  • -

#10 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Re: Winforms application design

Posted 03 May 2011 - 09:12 AM

View PostSergio Tapia, on 03 May 2011 - 05:09 PM, said:

Yep, user controls are one of the nicer ways I think. I've used them for many projects and they are easy enough to use.

I suggest using a Panel on the main form, and then dynamically loading the user control you need inside that Panel.


I did it with a tabbed panel. That way when the user clicks an item on the menu a new tab is added and the user control is loaded into it. I choose tabs because some of the views will load slow and once loaded, it is nice to have them open while you use the application.
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: Winforms application design

Posted 03 May 2011 - 09:22 AM

Hurray for me guessing right!
Was This Post Helpful? 0
  • +
  • -

#12 tashe  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 10-March 09

Re: Winforms application design

Posted 03 May 2011 - 09:24 AM

It's a great super power to have in situations like this. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1