public ComboDataGridView(DataGridView dataGridView, MyToolBar myToolBar, String table_name) { this.dataGridView = dataGridView; this.myToolBar = myToolBar; this.table_name = table_name; this.RowTemplate.Height = 20; operations.Add("И", "AND"); operations.Add("ИЛИ", "OR"); operations.Add("НЕ", "NOT"); // // Column1 // this.Column1.HeaderText = "Включен"; this.Column1.Name = "Column1"; // // Column2 // this.Column2.HeaderText = "Связь"; this.Column2.Name = "Column2"; this.Column2.Items.AddRange(new String[] { "И", "ИЛИ", "НЕ" }); //this.Column2.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // // Column3 // this.Column3.HeaderText = "Поле"; this.Column3.Name = "Column3"; //this.Column3.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // // Column4 // this.Column4.HeaderText = "Условие"; this.Column4.Name = "Column4"; this.Column4.Items.AddRange(new String[] { "=", "<>", ">", ">=", "<", "<=" }); //this.Column4.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // // Column5 // this.Column5.HeaderText = "Значение"; this.Column5.Name = "Column5"; //this.Column5.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { Column1, Column2, Column3, Column4, Column5 }); fillColumn3(); }
private void InitializeComponents() { //dataGridView.DataSourceChanged += sourceChanged; FillDataGridView(); myToolBar = new MyToolBar(option); if (tabs != null) { CreateTabs(); } dataGridView.Location = new System.Drawing.Point(0, 0); dataGridView.Dock = DockStyle.Fill; dataGridView.TabIndex = 1; dataGridView.SelectionChanged += new EventHandler(dataGridView_SelectionChanged); dataGridView.CellDoubleClick += cell_Click; dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.RowTemplate.Height = 15; dataGridView.BackgroundColor = Color.Honeydew; dataGridView.DataBindingComplete += DataSourceChanged; dataGridView.DataError += (s, e) => { }; if (option == FormWithFieldsOptions.chooseMultiple || option == FormWithFieldsOptions.Nothing) { dataGridView.MultiSelect = true; } else { dataGridView.MultiSelect = false; } searchTable = new ComboDataGridView(dataGridView, myToolBar, table_name); searchTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; searchTable.Location = new Point(0, 0); searchTable.Dock = DockStyle.Fill; SplitContainer splitContainer2 = new SplitContainer(); splitContainer2.Orientation = Orientation.Horizontal; splitContainer2.Dock = DockStyle.Fill; splitContainer2.SplitterWidth = 3; splitContainer2.BorderStyle = BorderStyle.Fixed3D; splitContainer2.Panel1.Controls.AddRange(new Control[] { searchTable }); splitContainer2.Panel2.Controls.AddRange(new Control[] { dataGridView }); splitContainer2.Panel1Collapsed = true; ts.Dock = DockStyle.Bottom; splitContainer2.Panel2.Controls.Add(ts); Label label = new Label(); //label.Dock = DockStyle.Fill; label.Text = (dataGridView.Tag as String); splitContainer3 = new SplitContainer(); splitContainer3.Orientation = Orientation.Vertical; splitContainer3.Dock = DockStyle.Fill; splitContainer3.SplitterWidth = 3; splitContainer3.BorderStyle = BorderStyle.Fixed3D; splitContainer3.Panel1.Controls.AddRange(new Control[] { splitContainer2 }); //splitContainer3.Panel2.Controls.AddRange(new Control[] { label }); splitContainer3.SplitterDistance = 750; splitContainer3.Panel2.BackColor = Color.Beige; pb.Dock = DockStyle.Fill; pb.SizeMode = PictureBoxSizeMode.Zoom; splitContainer3.Panel2Collapsed = !hasPhoto; //splitContainer3.Panel2Collapsed = true; if (hasPhoto) { splitContainer3.Panel2.Controls.Add(pb); } SplitContainer splitContainer1 = new SplitContainer(); splitContainer1.Dock = DockStyle.Fill; splitContainer1.Orientation = Orientation.Horizontal; splitContainer1.SplitterWidth = 3; splitContainer1.BorderStyle = BorderStyle.None; splitContainer1.Panel1.Controls.AddRange(new Control[] { splitContainer3 }); splitContainer1.Panel2.Controls.Add(tabControl); myToolBar.option = option; myToolBar.table_name = table_name; myToolBar.dataGridView = dataGridView; myToolBar.splitContainer = splitContainer2; myToolBar.Location = new Point(0, 0); myToolBar.BindingSource = (dataGridView.DataSource as BindingSource); if (sqlCommands == null || sqlCommands.Length == 0) { splitContainer1.Panel2Collapsed = true; } StatusStrip statusStrip = new StatusStrip(); statusStrip.Items.Add($"Книг всего: {quickData[0]} | В библиотеке: {quickData[1]} | На руках: {quickData[2]} | Читатели: {quickData[3]}"); TableLayoutPanel tableLayoutPanel = new TableLayoutPanel(); tableLayoutPanel.Dock = DockStyle.Fill; tableLayoutPanel.GrowStyle = TableLayoutPanelGrowStyle.AddRows; tableLayoutPanel.Controls.Add(myToolBar); tableLayoutPanel.Controls.Add(splitContainer1); //tableLayoutPanel.Controls.Add(statusStrip); control.Controls.Add(tableLayoutPanel); control.Controls.Add(statusStrip); dataGridView.Refresh(); if (dataGridView is IHaveMoreInfo) { WebBrowser lbl = new WebBrowser(); lbl.Dock = DockStyle.Fill; splitContainer3.Panel2.Controls.Add(lbl); splitContainer3.Panel2Collapsed = false; } try { String info = (dataGridView as DataGridViews.IHaveinfo).GetInfo(); Label lbl = new Label(); lbl.Text = info; lbl.Dock = DockStyle.Fill; //lbl.Width = 200; splitContainer3.Panel2.Controls.Add(lbl); //lbl.MaximumSize = new Size(lbl.Parent.Width - 10, 100); //lbl.AutoSize = true; lbl.Refresh(); splitContainer3.Panel2Collapsed = false; } catch (Exception ex) { } }