Results 1 to 13 of 13

Thread: Professional layout code problem

  1. #1

    Thread Starter
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Question Professional layout code problem

    Firstly Merry Christmas everyone

    I have been asked by a family member to create an application, but one thing that I have decided that I should do with this application is make the UI more professional.
    Up to now I have been creating applications which when I need more information I would open up a new form, but I would like to create an application which all is within the main form.

    After researching this I think the solution for this is to have the different bits in different panels and then only show the relevant panels at a particular time.
    But the problem I am having is getting my head around the problem with all the code. Using the panels method all the code would be in the main form, which when you have only a small amount of code then that would be fine but I'm thinking that with a larger application would make that a little more difficult as you may have hundreds of different panels.

    So while I will be using OOP, so there wouldn't be much business logic code on the form, there would still be a lot.
    So I am wondering if anyone had any suggestions on how I should go about doing this, if I'm using the wrong method then I would like to know what the more appropriate method would be.

    Thanks for any help in advance

    Satal

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Professional layout code problem

    you could use code regions to keep your code organized into 'regions'

    vb Code:
    1. Public Class Form1
    2.  
    3. #Region "panel1 code"
    4.     'put code related to panel1 in this region
    5. #End Region
    6.  
    7. #Region "panel2 code"
    8.     'put code related to panel2 in this region
    9. #End Region
    10.  
    11. end class

  3. #3

    Thread Starter
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: Professional layout code problem

    Yeah I love regions (I probably already use them too much). So I guess that its normal to just have lots of code in a form, and that is a quite normal way to have lots of content through one form.

    Thanks

  4. #4
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Professional layout code problem

    What is wrong with using multiple forms? Showing everything on a single form may be possible with small applications, but if it gets a little larger most applications really require multiple forms. And why shouldn't they?

    Anyway, without more information on what your application should do, and how you want it to look, we can't really help you; we can't tell you how to design a user interface if we have no clue what it should do!

  5. #5
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: Professional layout code problem

    You can use controls aswell.

    The problem with panels is that if you have 3 panels and you want to edit Panel1, you can't, you'd have to resize your form and "move away" Panel2 and Panel3 to get to Panel1.
    When using controls, you can put all controls on the main form and edit them separately =).

    *EDIT* This also solves your code problem
    All controls can have their own Code.vb =)

  6. #6

    Thread Starter
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: Professional layout code problem

    The application is a piece of software that deals with keeping a record of children attending a school, when they're supposed to be attending, the government funding that the school receives for the child attending, and works out the amount that the parents need to pay for what the government funding doesn't cover.
    Although while I am using this application as an opportunity for me to learn about how to create professional looking layout, I'm more interested in the actual methods suggested for creating large applications UI.
    Like for example the controls suggestion by Zeelia, which I assume means making each of the different screens into a control and then put that on the form, I hadn't thought about that and that's something that I will have to look into further to see if that would be appropriate for what I want to do.

  7. #7
    Addicted Member
    Join Date
    Jun 2009
    Posts
    245

    Re: Professional layout code problem

    One thing to consider is that some controls can be replaced by other controls. Like, a bunch of buttons can be replaced by one dropdown list when a user right clicks. Or you could replace a few listviews or something by using a TabControl and put them in different tabs (unless you need to view them at the same time).

    Just some things I learned when I started to focus on layout

  8. #8
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: Professional layout code problem

    While you may not have the time now, I would suggest you look at WPF. This new set of extensions to the .net framework allow you to really separate out the interface from the business code.

    WPF uses a new language called XAML to control the interface, while XAML can seem "magical" at first, as if it doesn't follow a structure once you get the hang of how it works you will find that its "magical" features are little more than shortcut's that are designed to make functional and dynamic interfaces easier to work with.

  9. #9
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: Professional layout code problem

    Yes, XAML is really great and you get a wider option of layout and graphics with it.
    For example, gradient colors which are great for buttons.

  10. #10
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Professional layout code problem

    All controls can have their own Code.vb =)
    Another alternative is to use partial classes - you can separate logical groups of code into partial classes which at compile time all become part of the same class.

    VB actually already uses this to keep the designer code separate from the user code.

  11. #11
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: Professional layout code problem

    If you are not keen on WPF I would at least second keystone paul's idea and split the design code into a partial class if at least for readability.

  12. #12

    Thread Starter
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: Professional layout code problem

    @keystone_paul, ooow I hadn't thought about that, yes that sounds like a good idea.

    @DeanMc sounds like MVC for desktop applications, I will definitely have to look into this.

    Thank you everyone for your suggestions they have been very useful, although if you do have any other suggestions then I will more than welcome them

  13. #13
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: Professional layout code problem

    Actually it is a different concept all together but once you get the hang of it you will understand why it is gaining popularity so fast!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width