none
Matrix model Table with Dynamic Controls in Windows Form RRS feed

  • Question

  • hi all,

       I am working like ERP product . Now i need to show a warehouse structure which contains row and columns. The table shows the entire structure with Cell name . If disabled need to show as different color and others different color with link enabled. So user can allocate goods to that are. Which control is better for this. 

      First i tried table layout panel. But very slow and rendering is bad. I also tried with double buffered. But for big warehouse like 100 x 100 this not helped. Now i got one idea from one article like simply add controls to the panel and it is nice. But positioning controls and some work is tedious. The following are the code for that

            const int RowCount = 20;
            const int ColumnCount = 20;
            private void Form1_Load(object sender, EventArgs e)
            {
                for (int i = 0; i < RowCount; i++)
                {
                    for (int j = 0; j < ColumnCount; j++)
                    {
                        Panel controlHolder = new Panel();
                        controlHolder.BorderStyle = BorderStyle.FixedSingle;
                        
                        controlHolder.Size = new Size(30, 30);
                        controlHolder.Location = new Point(i * 30, j * 30);
                        CheckBox c = new CheckBox();
                        controlHolder.Margin = Padding.Empty;
                        //c.Left = (lbl.Width) / 2;
                        //c.Top = (lbl.Height) / 2;
                        if ((i + j) % 2 == 0)
                        {
                            controlHolder.Controls.Add(c);
                        }
                        else
                        {
                            controlHolder.BackColor = Color.Black;
                        }
                        //lbl.BackColor = (i + j) % 2 == 0 ? Color.Black : Color.White;
                        panel1.Controls.Add(controlHolder);
                    }
                }
            }
    Kindly help to find a suitable control for his or my idea is correct for my situation? Datagridview i think some more complex for this custom criteria and back color changing like dynamic behavior change. Kindly advise me for this

    Monday, April 1, 2013 1:41 AM

Answers