Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Distorted Controls

Distorted Controls

Scheduled Pinned Locked Moved C#
designhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wamuti
    wrote on last edited by
    #1

    Hi. I have controls that are being loaded at run time. Initially when they are loaded they appear as they should be but when i minimize the windows form, and restore it, they add extra spaces between them. This curious behaviour is really threatening my sanity :mad: because i have gone through the source code (for the 100th time :doh: )and there appears to be no problem with it. Below is the source:

    private void ShowQuestionsAndAnswers(ArrayList questions, ArrayList answers)
    {

            groupBox2.Enabled = true;
            j = 0;
    
            for (int i = 0; i < questions.Count; i++)
            {
                tbp.Invalidate();
                j = i;
                ArrayList ans = new ArrayList();
                
                GroupBox gb = new GroupBox();
                //gb.AutoSize = true;
                gb.Size = new Size(tbp.Width - 100, 150);
                tbp.Controls.Add(gb); // Adding the groupbox to the main table panel added during design time.
                TableLayoutPanel tbp2 = new TableLayoutPanel();// a panel for the controls inside the group box
                tbp2.ColumnCount = 1; // ensure that there is only one column in the panel inside the group box
                tbp2.AutoSize = true;
                gb.Controls.Add(tbp2);// add the panel in the group box
                // Make the controls (a label and four radiobuttons)i want to use ready
                Label newLabel = new Label();
                //gb.Text = examsQuestions\[i\].ToString();
                newLabel.Text = (i + 1).ToString() + ". " + questions\[i\].ToString();
                newLabel.AutoSize = true;
                newLabel.BringToFront();
                newLabel.Size = new Size(1000, 100);
                RadioButton rdb1 = new RadioButton();
                rdb1.AutoSize = true;
                tbp2.SetRow(rdb1, 1);
                rdb1.Text = a\[0\].ToString();
                rdb1.Click += new EventHandler(rdb\_Click);
                
    
    
                RadioButton rdb2 = new RadioButton();
                rdb2.AutoSize = true;
                tbp2.SetRow(rdb2, 2);
                rdb2.Text = a\[1\].ToString(); ;
                rdb2.Click += new EventHandler(rdb\_Click);
    
                RadioButton rdb3 = new RadioButton();
                rdb3.AutoSize = true;
                rdb3.Text = a\[2\].ToString(); ;
                rdb3.Click += new EventHandler(rdb\_Click);
    
                RadioButton rdb4 = n
    
    OriginalGriffO 1 Reply Last reply
    0
    • W Wamuti

      Hi. I have controls that are being loaded at run time. Initially when they are loaded they appear as they should be but when i minimize the windows form, and restore it, they add extra spaces between them. This curious behaviour is really threatening my sanity :mad: because i have gone through the source code (for the 100th time :doh: )and there appears to be no problem with it. Below is the source:

      private void ShowQuestionsAndAnswers(ArrayList questions, ArrayList answers)
      {

              groupBox2.Enabled = true;
              j = 0;
      
              for (int i = 0; i < questions.Count; i++)
              {
                  tbp.Invalidate();
                  j = i;
                  ArrayList ans = new ArrayList();
                  
                  GroupBox gb = new GroupBox();
                  //gb.AutoSize = true;
                  gb.Size = new Size(tbp.Width - 100, 150);
                  tbp.Controls.Add(gb); // Adding the groupbox to the main table panel added during design time.
                  TableLayoutPanel tbp2 = new TableLayoutPanel();// a panel for the controls inside the group box
                  tbp2.ColumnCount = 1; // ensure that there is only one column in the panel inside the group box
                  tbp2.AutoSize = true;
                  gb.Controls.Add(tbp2);// add the panel in the group box
                  // Make the controls (a label and four radiobuttons)i want to use ready
                  Label newLabel = new Label();
                  //gb.Text = examsQuestions\[i\].ToString();
                  newLabel.Text = (i + 1).ToString() + ". " + questions\[i\].ToString();
                  newLabel.AutoSize = true;
                  newLabel.BringToFront();
                  newLabel.Size = new Size(1000, 100);
                  RadioButton rdb1 = new RadioButton();
                  rdb1.AutoSize = true;
                  tbp2.SetRow(rdb1, 1);
                  rdb1.Text = a\[0\].ToString();
                  rdb1.Click += new EventHandler(rdb\_Click);
                  
      
      
                  RadioButton rdb2 = new RadioButton();
                  rdb2.AutoSize = true;
                  tbp2.SetRow(rdb2, 2);
                  rdb2.Text = a\[1\].ToString(); ;
                  rdb2.Click += new EventHandler(rdb\_Click);
      
                  RadioButton rdb3 = new RadioButton();
                  rdb3.AutoSize = true;
                  rdb3.Text = a\[2\].ToString(); ;
                  rdb3.Click += new EventHandler(rdb\_Click);
      
                  RadioButton rdb4 = n
      
      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Do you handle an Resize event?

      You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups