Example #1
0
        public void initTableLayoutPanel()
        {
            //panel.AutoSize = true;
            panel.ColumnCount = 3;
            panel.RowCount    = 7;
            panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 15F));
            panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
            panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
            //panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 18.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));
            panel.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 12.5F));


            panel.Size        = new Size(402, 300);
            panel.BorderStyle = BorderStyle.FixedSingle;

            panel.Padding = new Padding(25, 30, 15, 25);

            //adding labels to table
            for (int i = 0; i < labelArr.Length - 2; i++)
            {
                panel.Controls.Add(labelArr[i], 0, i);
            }

            //adding textboxes to table
            for (int i = 0; i < secondColumnObjArr.Length - 2; i++)
            {
                if (secondColumnObjArr[i] is TextBox)
                {
                    panel.Controls.Add((TextBox)secondColumnObjArr[i], 1, i);
                }
                else if (secondColumnObjArr[i] is CheckBox)
                {
                    panel.Controls.Add((CheckBox)secondColumnObjArr[i], 1, i);
                }
                else if (secondColumnObjArr[i] is DateTimePicker)
                {
                    panel.Controls.Add((DateTimePicker)secondColumnObjArr[i], 1, i);
                }
                else
                {
                    panel.Controls.Add((ListBox)secondColumnObjArr[i], 1, i);
                    //panel.SetRowSpan((ListBox)secondColumnObjArr[i], 2);
                }
            }
            DoubleBufferedTableLayoutPanel p1 = new DoubleBufferedTableLayoutPanel();

            p1.ColumnCount = 2;
            p1.RowCount    = 1;
            p1.Size        = startTime.Size;

            p1.Controls.Add(labelArr[labelArr.Length - 1], 0, 0);
            p1.Controls.Add((CheckBox)secondColumnObjArr[secondColumnObjArr.Length - 1], 1, 0);
            panel.Controls.Add(p1, 2, 4);

            DoubleBufferedTableLayoutPanel p2 = new DoubleBufferedTableLayoutPanel();

            p2.ColumnCount = 2;
            p2.RowCount    = 1;
            p2.Size        = startTime.Size;

            p2.Controls.Add(labelArr[labelArr.Length - 2], 0, 0);
            p2.Controls.Add((CheckBox)secondColumnObjArr[secondColumnObjArr.Length - 2], 1, 0);
            panel.Controls.Add(p2, 2, 3);

            //panel.Controls.Add(labelArr[labelArr.Length - 1], 2, 3);
            //panel.Controls.Add(labelArr[labelArr.Length - 2], 2, 4);
            //panel.Controls.Add((CheckBox)secondColumnObjArr[secondColumnObjArr.Length - 1], 3, 3);
            //panel.Controls.Add((CheckBox)secondColumnObjArr[secondColumnObjArr.Length - 2], 3, 4);

            ////adding a mighty button to submit new event
            panel.Controls.Add(btnSubmit, 1, 6);

            // adding time pickers
            panel.Controls.Add(startTime, 2, 1);
            panel.Controls.Add(endTime, 2, 2);
            //panel.SetColumnSpan(startTime, 2);
            //panel.SetColumnSpan(endTime, 2);
        }
Example #2
0
        private void InitCalendarHeader()
        {
            weekdayLabels = new Label[7];// seven weekdayLabels
            Color foreColor       = Color.FromArgb(255, 61, 0, 85);
            Color backgrColor     = Color.FromArgb(255, 227, 223, 213);
            Color SundayForeColor = Color.FromArgb(255, 204, 0, 0);
            Color SundayBackColor = Color.FromArgb(255, 255, 243, 230);

            for (int i = 0; i < weekdayLabels.Length; i++)
            {
                weekdayLabels[i] = new Label();

                weekdayLabels[i].Font = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);

                weekdayLabels[i].TextAlign = ContentAlignment.MiddleCenter;
                weekdayLabels[i].Anchor    = (AnchorStyles.Left | AnchorStyles.Right);
                weekdayLabels[i].AutoSize  = false;

                weekdayLabels[i].BorderStyle = BorderStyle.FixedSingle;

                weekdayLabels[i].ForeColor = foreColor;
                weekdayLabels[i].BackColor = backgrColor;
            }
            //Set Label Anchor to Left and Right
            //Set Label AutoSize to false;
            //Set Label TextAlign to MiddleCenter;

            weekdayLabels[6].BackColor = SundayBackColor;
            // asigning weekday strings
            {
                weekdayLabels[0].Text = "Monday";
                weekdayLabels[1].Text = "Tuesday";
                weekdayLabels[2].Text = "Wednesday";
                weekdayLabels[3].Text = "Thursday";
                weekdayLabels[4].Text = "Friday";
                weekdayLabels[5].Text = "Saturday";
                weekdayLabels[6].Text = "Sunday";
            }

            weekdaysRow             = new DoubleBufferedTableLayoutPanel();
            weekdaysRow.RowCount    = 1;
            weekdaysRow.ColumnCount = 7;
            float ColumnSize = 14.28f;

            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));
            weekdaysRow.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, ColumnSize));

            weekdaysRow.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);

            weekdaysRow.Dock        = DockStyle.Fill;
            weekdaysRow.Size        = new System.Drawing.Size(995, 50);
            weekdaysRow.Height      = 35;
            weekdaysRow.BorderStyle = BorderStyle.FixedSingle;
            weekdaysRow.BackColor   = Color.FromArgb(255, 206, 201, 192);

            headers = new Panel[7]; // seven panels for each weekday label

            for (int i = 0; i < headers.Length; i++)
            {
                headers[i] = new Panel();
                //headers[i].Dock = DockStyle.Top;
                headers[i].Size        = new Size(991 / 7 - 5, 25);
                headers[i].BorderStyle = BorderStyle.FixedSingle;

                headers[i].BackColor = backgrColor;
                headers[i].Anchor    = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top);
                Centroid(weekdayLabels[i], headers[i]);
                headers[i].Controls.Add(weekdayLabels[i]);

                weekdaysRow.Controls.Add(headers[i], i, 0);
            }
            headers[6].BackColor = SundayBackColor;

            frame.Controls.Add(weekdaysRow, 1, 3);
            frame.SetColumnSpan(weekdaysRow, 7);
        }