Results 1 to 8 of 8

Thread: [RESOLVED] [3.0/linq]

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Resolved [RESOLVED] [3.0/linq]

    Hi All,

    When my form re-sizes I would like a text box that I have to grow up to the size of the group box that it is in but leave some room for a command button to the right of the text box. Currently I am using the following code.
    Code:
    this.txtFilePath.Width = this.groupBox.Width -
                             this.groupBox.Padding.Left -
                             this.groupBox.Padding.Right -
                             this.txtFilePath.Margin.Left -
                             this.txtFilePath.Margin.Right -
                             this.cmdBrowse.Margin.Left -
                             this.cmdBrowse.Width -
                             this.cmdBrowse.Margin.Right;
    Which works fine, I am wondering if there was a better way to write this code?

    The text box is anchored top left and the command button is anchored top right.

    Thanks Steve
    Attached Images Attached Images  
    This space for rent...

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: [3.0/linq]

    I'm not sure I understand why you're using code for this as anchoring it top, left and right should do what you need, relative to its container

  3. #3
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: [3.0/linq]

    Anchor the textbox "right" along witht he 2 you have specified. Since you want it to grow in all directions, it'll be aware of the relationship to the width of its parent also.

  4. #4

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Re: [3.0/linq]

    Thank you I will give that a try, sure beats writing the code.
    This space for rent...

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/linq]

    The Button should be anchored Top, Right and the TextBox should be anchored Top, Left, Right.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: [3.0/linq]

    Try
    Code:
    frm.autoscalemode=Inhert
    form.scale(scalefactor)
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  7. #7

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Re: [3.0/linq]

    That was so stupid easy.

    Since I had your attention, I thought I would add another text box in between the button and the first text box to see what would happen. Unfortunately the boxes ended up on top of each other. In my first example the textbox1 was able to right anchor to the button which it is still doing. textbox2 is also anchoring to the button. Is there a way to get textbox1 to anchor to textbox2 and textbox2 to anchor to the button?

    Obviously the more complicated the form gets the docking and anchor features of the components will only get you so far and then you are going to need to start coding.

    I will take a look at trying to determine how much the form was scaled up or down and the adjust my controls accordingly. However I do not think it will work that well since some of my components will not be changing sizes, like the button. So the scale factor will not be exactly the same.
    Attached Images Attached Images  
    This space for rent...

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/linq]

    Use a TableLayoutPanel with 1 row and 2 columns at 50% each. Anchor it as you did the TextBox and dock or anchor the TextBoxes in the cells.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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