protected static void BringUpCurrentTab(Control ctl) { Control page = TabPage.GetTabPageOfComponent(ctl); //process standard tab control if (page != null) { ((TabControl)page.Parent).SelectedTab = (TabPage)page; BringUpCurrentTab(page.Parent.Parent); return; } //XtraTabControl page = ctl; //.Parent while (page != null) { var selectedTabPage = page as XtraTabPage; if (selectedTabPage != null) { (selectedTabPage).TabControl.SelectedTabPage = selectedTabPage; BringUpCurrentTab((selectedTabPage).TabControl.Parent); return; } page = page.Parent; } }
private void InitializeMyTabs() { tabControl1 = new System.Windows.Forms.TabControl(); tabPage1 = new System.Windows.Forms.TabPage(); tabPage2 = new System.Windows.Forms.TabPage(); button1 = new System.Windows.Forms.Button(); button2 = new System.Windows.Forms.Button(); tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] { tabPage1, tabPage2 }); tabControl1.Location = new System.Drawing.Point(40, 24); tabControl1.Size = new System.Drawing.Size(216, 216); tabControl1.TabIndex = 0; tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] { button1 }); tabPage1.TabIndex = 0; tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] { button2 }); tabPage2.TabIndex = 1; button1.Location = new System.Drawing.Point(64, 72); button2.Location = new System.Drawing.Point(64, 72); button2.Text = "button2"; ClientSize = new System.Drawing.Size(292, 273); Controls.AddRange(new System.Windows.Forms.Control[] { tabControl1 }); // Gets the index of the TabPage containing button2. // Selects the index of the TabPage containing button2. tabControl1.SelectedIndex = (TabPage.GetTabPageOfComponent(button2)).TabIndex; }
private void Form1_Load(object sender, EventArgs e) { string str = Application.StartupPath + "/map.html"; Uri uri = new Uri(str); webBrowser1.Url = uri; webBrowser1.ObjectForScripting = TabPage.GetTabPageOfComponent(webBrowser1); }
private void btnXoaTG_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn xóa?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); bool result = false; if (dialogResult == DialogResult.OK) { // đồng ý xóa: xóa trong db rồi refresh dtgv switch (TabPage.GetTabPageOfComponent((Control)sender).Text) { case "Tác Giả ": { result = DAL.Sach_DAL.Instance.DeleteTacGia(Convert.ToInt32(dtgv_dsTacGia.CurrentRow.Cells["MaTacGia"].Value)); break; } case "NXB": { result = DAL.Sach_DAL.Instance.DeleteNXB(Convert.ToInt32(dtgv_NXB.CurrentRow.Cells["MaNXB"].Value)); break; } case "Thể Loại": { result = DAL.Sach_DAL.Instance.DeleteTheLoai(Convert.ToInt32(dtgv_TheLoai.CurrentRow.Cells["MaKeSach"].Value)); break; } case "Đầu Sách ": { result = DAL.Sach_DAL.Instance.DeleteDauSach(Convert.ToInt32(dtgv_DauSach.CurrentRow.Cells["MaDauSach"].Value)); break; } case "Cuốn Sách": { result = DAL.Sach_DAL.Instance.DeleteCuonSach(Convert.ToInt32(dtgv_CuonSach.CurrentRow.Cells["MaCuonSach"].Value)); break; } default: result = false; break; } if (result) { MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Có lỗi xảy ra", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //cancel xóa } }
private void btnLuuTG_Click(object sender, EventArgs e) { switch (TabPage.GetTabPageOfComponent((Control)sender).Text) { case "Tác Giả ": { #region save thông tin mới update if (this.themMoi == 1) { DAL.Sach_DAL.Instance.InsertTacGia( Convert.ToInt32(tbMaTG.Text), tbTenTG.Text ); } else { DAL.Sach_DAL.Instance.UpdateTacGia( Convert.ToInt32(tbMaTG.Text), tbTenTG.Text ); } #endregion break; } case "NXB": { #region save thông tin mới update if (this.themMoi == 1) { DAL.Sach_DAL.Instance.InsertNXB( Convert.ToInt32(tbMaNXB.Text), tbTenNXB.Text, tbDiaChiNXB.Text, Convert.ToInt32(tbSdtNXB.Text) ); } else { DAL.Sach_DAL.Instance.UpdateNXB( Convert.ToInt32(tbMaNXB.Text), tbTenNXB.Text, tbDiaChiNXB.Text, Convert.ToInt32(tbSdtNXB.Text) ); } #endregion break; } case "Thể Loại": { #region save thông tin mới update if (this.themMoi == 1) { DAL.Sach_DAL.Instance.InsertTheLoai( Convert.ToInt32(tbMaKeSach.Text), tbTenTheLoai.Text ); } else { DAL.Sach_DAL.Instance.UpdateTheLoai( Convert.ToInt32(tbMaKeSach.Text), tbTenTheLoai.Text ); } #endregion break; } case "Đầu Sách ": { #region save thông tin mới update if (this.themMoi == 1) { DAL.Sach_DAL.Instance.InsertDauSach( Convert.ToInt32(tbMaDauSach.Text), tbTenDauSach.Text, Convert.ToInt32(tbMaNXB_DauSach.Text) ); } else { DAL.Sach_DAL.Instance.UpdateDauSach( Convert.ToInt32(tbMaDauSach.Text), tbTenDauSach.Text, Convert.ToInt32(tbMaNXB_DauSach.Text) ); } #endregion break; } case "Cuốn Sách": { #region save thông tin mới update if (this.themMoi == 1) { DAL.Sach_DAL.Instance.InsertCuonSach( Convert.ToInt32(tbMaCuonSach.Text), tbTenCuonSach.Text, Convert.ToInt32(tbSoTrang.Text), tbTinhTrang.Text, Convert.ToInt32(tbMaDauSach_CuonSach.Text), Convert.ToInt32(tbMaKeSach_CuonSach.Text) ); } else { DAL.Sach_DAL.Instance.UpdateCuonSach( Convert.ToInt32(tbMaCuonSach.Text), tbTenCuonSach.Text, Convert.ToInt32(tbSoTrang.Text), tbTinhTrang.Text, Convert.ToInt32(tbMaDauSach_CuonSach.Text), Convert.ToInt32(tbMaKeSach_CuonSach.Text) ); } #endregion break; } default: break; } this.themMoi = 0; // save thông tin mới update groupBox1.Enabled = false; groupBox4.Enabled = false; groupBox5.Enabled = false; groupBox8.Enabled = false; groupBox10.Enabled = false; ClearTextBoxes(this); UnDisableBtnEdit(this); btnLuuTG.Enabled = false; btnHuyTG.Enabled = false; btnThemTG.Enabled = true; btnSuaTG.Enabled = true; btnXoaTG.Enabled = true; dtgv_dsTacGia.DataSource = DAL.Sach_DAL.Instance.GetListTacGia(); dtgv_DauSach.DataSource = DAL.Sach_DAL.Instance.GetListDauSach(); dtgv_NXB.DataSource = DAL.Sach_DAL.Instance.GetListNXB(); dtgv_TheLoai.DataSource = DAL.Sach_DAL.Instance.GetListTheLoai(); dtgv_CuonSach.DataSource = DAL.Sach_DAL.Instance.GetListCuonSach(); dtgv_dsTacGia.Refresh(); dtgv_CuonSach.Refresh(); dtgv_DauSach.Refresh(); dtgv_NXB.Refresh(); dtgv_TheLoai.Refresh(); MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }