F How to show Database value grid wise in to tabControl in C# ? | CodeTheta

How to show Database value grid wise in to tabControl in C# ?


//tab control function
        private void TabPageDepartmentChoose() {
            DataTable dt = c.Select();
            FlowLayoutPanel flp = new FlowLayoutPanel();
            flp.Dock = DockStyle.Fill;
            foreach (DataRow dr in dt.Rows) {
                Button button = new Button();
                button.Size = new Size(100, 50);
                button.Text = dr["department_name"].ToString();
                flp.Controls.Add(button);
                button.Click += new EventHandler(DynamicButtonDepartment_Click);
            }
            tabPageDepartmentChoose.Controls.Add(flp);
        }
//dynamic button click event for tab control button
        protected void DynamicButtonDepartment_Click(object sender, EventArgs e) {
            this.Hide();
            frmDashboard frm = new frmDashboard();
            frm.Show();
        }
//code for datatable access and TabPageDepartmentChoose() show during form run time.
DataTable dt = c.Select();
TabPageDepartmentChoose();

IDE Used To Test This Code : Visual Studio.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment