visual c# - help asap please!

Discussion in 'Software' started by sheepondrugs, May 9, 2007.

  1. sheepondrugs

    sheepondrugs Private First Class

    how can i change the size of a form window when the program is running?

    for example:

    MainForm.height = 400;



    this is the small peice of code,



    if (MsgResize == DialogResult.Yes)
    {

    MessageBox.Show("Form window will now re-size", "TITLE",
    MessageBoxButtons.OK,
    MessageBoxIcon.Information);

    // resize code here ----------------------


    }

    any ideas?


    thanks alot


    'Chris
     
  2. Wyatt_Earp

    Wyatt_Earp MajorGeek

    Code:
    if (MsgResize == DialogResult.Yes)
    {
    
    MessageBox.Show("Form window will now re-size", "TITLE",
    MessageBoxButtons.OK,
    MessageBoxIcon.Information);
    
    // resize code here ----------------------
    
    
    }
    Assuming this dialogbox is being instantiated from the mainform that you want to resize, try using the 'this' variable.
     
  3. matt.chugg

    matt.chugg MajorGeek

    10 seconds more and you could have written the code ;)

    Code:
    this.Size=new Size(x,y);
    
    If you want to set the form size to a percentage of then you will need to get the screen working area using

    Code:
    Screen.GetWorkingArea(this); [COLOR="SeaGreen"]// returns rect.[/COLOR]
    
     
  4. Wyatt_Earp

    Wyatt_Earp MajorGeek

    I know. I was trying to avoid doing his homework for him. (If that was the case) Otherwise, he'll just learn it better if he does a little research on his own. ;)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds