Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# Design Problem

Options
  • 12-04-2006 3:53am
    #1
    Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,079 Mod ✭✭✭✭


    Hello all

    I am trying to make a horizontal line the length of my windows form go across the form and half way across that a vertical line go straight down (basically like a giant T. I want to put things(e.g labels, text boxes, data grids and the like) on either side of the vertical line so that rules out a giant label with "T" in some huge font.

    I can't for the life of me think of a way to do it though.

    Can anybody help me out. If you can you get a lollipop. No kidding.


Comments

  • Registered Users Posts: 2,082 ✭✭✭Tobias Greeshman


    Look at C#'s GDI+ Functions.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    The quick and easy way would be to drop a panel at the top of the form to give you something like
    xxxxxxxxxxxxxxx
    x             x
    x             x
    x-------------x
    x             x
    x             x
    x             x
    x             x
    xxxxxxxxxxxxxxx
    

    then drop two more below it giving
    xxxxxxxxxxxxxxx
    x             x
    x             x
    x-------------x
    x         |   x
    x         |   x
    x         |   x
    x         |   x
    xxxxxxxxxxxxxxx
    

    You should also be able to use splitters, or splitpanels depending on what version of C# you're using, to allow the user to resize as nessecary (if using splitters in the first step you'd drop two panels with a splitter between them, then in the second step put your two panels and second splitter in the bottom one.)


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,079 Mod ✭✭✭✭AlmightyCushion


    I decided to use 2 panels. I resized them to look like lines (a verticle one and a horizontal one), then just changed their background colour to a darker colour and positioned them where I wanted. The lines are a little thicher than I wanted but I'll have to make do.

    I would have used the graphics functions but way too complicated for my liking. I might go back when I'm finished and use the graphics fuction if I have time


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Unless there's some reason you can't use custom controls, I'd do a google for "c# Line Control" myself. There's no shortage of free controls (with or without source) available to take the place of the inexplicably-missing Line Control.

    I was staggered when I found this wasn't in .Net by default...its been in VB as long as I remember.


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,079 Mod ✭✭✭✭AlmightyCushion


    It's for a project for college so I have to code it all myself but I might give it a shot and see what I find because those two panels are really getting to me. I just can't make them any thinner. AARRRGGGG!!


  • Advertisement
  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    If you google the term I supplied above, you'll see that one of the early hits (first page) is from somewhere liek codeproject.com....

    Here, you'll get teh code for a control as well as the control itself. It might give you enough code to look at to figure out what you need to do....

    jc


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,079 Mod ✭✭✭✭AlmightyCushion


    Yeah I looked that up and it doesn't seem that bad. I might give it a go later tonight(Probably at like four in the morning).

    Thanks bonkey.

    Another problem I'm having is validating an e-mail address entered by a user.

    I don't need something fancy that checks if the e-mail address actually exists. I just need to check if there is a bit of text followed by "@ a bit more text followed by ." followed by a bit more text.

    I need checking for illegal characters. I am currently saving each line of the string as a char and iterating through eac element of the string. Then I compare that char to the illegal character. If its true then increment a count. There has to be an easier way.............I hope

    Everything I find on the internet is on checking if the address actually exists. While that would be pretty cool it is kinda overkill though.

    Thanks for any help on this.


  • Registered Users Posts: 362 ✭✭theone


    you can validate your email address using regular expressions
    public static bool isEmail(string inputEmail)
    {
       inputEmail  = NulltoString(inputEmail);
       string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
             @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + 
             @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
       Regex re = new Regex(strRegex);
       if (re.IsMatch(inputEmail))
        return (true);
       else
        return (false);
    }
    
    
    from
    http://www.codeproject.com/aspnet/Valid_Email_Addresses.asp

    to make your panels thinner go to the size property on the panel properites nd your given x and y coords just change the x coord to 2 for a line.
    change the backcolour to black and the border style to fixedsingle.


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,079 Mod ✭✭✭✭AlmightyCushion


    Thanks theone.

    Both those suggestions worked great.

    I had only changed the size of the panels visually ,I never thought of changing the size in the properties panel (in hindsight it seems kinda obvious).

    The email thing while I haven't tested it completely seems to be working pretty well.

    Thanks again man. I'll get you that lollipop as soon as it becomes possible to e-mail inanimate objects. Chances are I'll be needing your help again guys and it'll probably be sooner rather than later.


Advertisement