locked
Form with textbox: how to enable autosize? RRS feed

  • Question

  • I've got a form with a textbox. How do I enable autosize such that the form always has the correct (minimal) height?
    When I set AutoSizeMode to GrowAndShrink, the form is 0 x 0.
    Wednesday, December 16, 2009 2:45 PM

Answers


  • When AutoSize mode is enabled, your form will adjust to make sure that controls are properly visible.

    When Grow and Shrink is selected, form will shrink when there is space without controls on your form. Hence form will be drawn upto bottom-right corner of control placed in far bottom-right corner of your form.

    Your form goes 0x0 most probably because you dont have controls on it.


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Friday, December 18, 2009 12:48 PM
    • Marked as answer by Jing0 Wednesday, December 23, 2009 4:53 AM
    Wednesday, December 16, 2009 4:55 PM

All replies


  • When AutoSize mode is enabled, your form will adjust to make sure that controls are properly visible.

    When Grow and Shrink is selected, form will shrink when there is space without controls on your form. Hence form will be drawn upto bottom-right corner of control placed in far bottom-right corner of your form.

    Your form goes 0x0 most probably because you dont have controls on it.


    Thanks

    My BlogMy FacebookYOUR Place to have fun time ! Awesome RPG Action Game
    • Proposed as answer by Omie Friday, December 18, 2009 12:48 PM
    • Marked as answer by Jing0 Wednesday, December 23, 2009 4:53 AM
    Wednesday, December 16, 2009 4:55 PM
  • The form does contain a textbox, so that can't be the reason.
    Wednesday, December 23, 2009 5:42 PM

  • What happens if you set AutoSizeMode to GrowOnly ?

    could you zip a sample project and upload it to skydrive.live.com or rapidshare.com ? I'm not able to reproduce it here, not getting any clue either. Just make sure it has similar settings for Form and it goes 0x0 even when it has a textbox on it.


    Thanks

    My BlogMy Facebook
    Wednesday, December 23, 2009 5:46 PM
  • http://rapidshare.com/files/338835461/AutoSize.zip.html








    void InitializeComponent(void) { this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // textBox1 // this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill; this->textBox1->Location = System::Drawing::Point(0, 0); this->textBox1->MinimumSize = System::Drawing::Size(100, 20); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(292, 20); this->textBox1->TabIndex = 0; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->AutoSize = true; this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink; this->ClientSize = System::Drawing::Size(292, 273); this->Controls->Add(this->textBox1); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); this->PerformLayout(); }
    Thursday, January 21, 2010 4:09 PM