[RESOLVED] Group Box Drawing Error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Group Box Drawing Error

  1. #1
    Join Date
    Jan 2012
    Posts
    18

    [RESOLVED] Group Box Drawing Error

    Hey guys,

    I am checking a bunch of strings and adding controls if the strings match a pattern determined by some Regex logic. The problem is some of the stuff I am adding doesn't show.

    I have commented out portions of the code below and it all works, everything shows individually but when I run the full routine (nothing commented out) only the CheckBoxes and "Installed:" labels show.

    I have tried forcing an Update and Refresh on my groupbox and nothing.

    What is going on here?

    Code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;
    
    namespace StartupInstall
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                string[] numbers = 
                {
                textBox1.Text,
                textBox2.Text,
                textBox3.Text,
                };
    
                string sPattern = @"^"".+""$";
                textBox5.Text = sPattern;
                int arrayPos = -1;
                int progPos = 0;
                Label[] labelNameRef = new Label[3];
                Label[] labelInstalledRef = new Label[3];
                Label[] labelStatusRef = new Label[3];
                CheckBox[] checkboxRef = new CheckBox[3];
                
                foreach (string s in numbers)
                {
                    textBox4.AppendText(Environment.NewLine + s);
    
                    if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern))
                    {
                        textBox4.AppendText(Environment.NewLine + " - valid");
                        arrayPos++;
                        progPos++;
    
                        checkboxRef[arrayPos] = new CheckBox();
    
                        checkboxRef[arrayPos].Name = "programCB" + progPos.ToString();
                        checkboxRef[arrayPos].Text = progPos.ToString();
                        checkboxRef[arrayPos].Location = new Point(6, 17 + (24 * arrayPos));
    
                        groupBox1.Controls.Add(checkboxRef[arrayPos]);
                        //
                        labelNameRef[arrayPos] = new Label();
    
                        labelNameRef[arrayPos].Name = "programLAB" + progPos.ToString();
                        labelNameRef[arrayPos].Text = "program " + progPos.ToString();
                        labelNameRef[arrayPos].Location = new Point(44, 22 + (23 * arrayPos));
    
                        groupBox1.Controls.Add(labelNameRef[arrayPos]);
                        //
                        labelInstalledRef[arrayPos] = new Label();
    
                        labelInstalledRef[arrayPos].Name = "installedLAB" + progPos.ToString();
                        labelInstalledRef[arrayPos].Text = "Installed:";
                        labelInstalledRef[arrayPos].Location = new Point(248, 22 + (23 * arrayPos));
    
                        groupBox1.Controls.Add(labelInstalledRef[arrayPos]);
                        //
                        labelStatusRef[arrayPos] = new Label();
    
                        labelStatusRef[arrayPos].Name = "statusLAB" + progPos.ToString();
                        labelStatusRef[arrayPos].Text = "YES";
                        labelStatusRef[arrayPos].Location = new Point(303, 22 + (23 * arrayPos));
    
                        groupBox1.Controls.Add(labelStatusRef[arrayPos]);
                        groupBox1.Refresh();
                    }
                    else
                    {
                        textBox4.AppendText(Environment.NewLine + " - invalid");
                    }
                }
            }
        }
    }
    Last edited by Fluidz; March 2nd, 2012 at 11:35 PM. Reason: To Mark Solved

  2. #2
    Join Date
    Jan 2012
    Posts
    18

    Re: Group Box Drawing Error

    Solved, turns out the controls were being sent to the back for some reason. All I did was add var[ArrayPos].BringToFront(); on each section and it's working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center