/// <summary> /// Paints common elements behind the cell content. /// </summary> /// <param name="graphics"></param> /// <param name="cellBounds"></param> /// <param name="cellState"></param> /// <param name="cellStyle"></param> /// <param name="paintParts"></param> protected void BeforePaintContent(Graphics graphics, Rectangle cellBounds, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts) { if (paintParts.HasFlag(DataGridViewPaintParts.Background)) { using (Brush brush = new SolidBrush(cellStyle.BackColor)) { graphics.FillRectangle(brush, cellBounds); } } if (paintParts.HasFlag(DataGridViewPaintParts.SelectionBackground) && cellState.HasFlag(DataGridViewElementStates.Selected)) { using (Brush brush = new SolidBrush(cellStyle.SelectionBackColor)) { graphics.FillRectangle(brush, cellBounds); } } if (paintParts.HasFlag(DataGridViewPaintParts.ContentBackground)) { ComboBoxState state = ComboBoxState.Normal; ButtonState legacyState = ButtonState.Normal; if ((DataGridView.Site == null) || !DataGridView.Site.DesignMode) { if (cellState.HasFlag(DataGridViewElementStates.ReadOnly)) { state = ComboBoxState.Disabled; legacyState = ButtonState.Inactive; } else if (cellBounds.Contains(DataGridView.PointToClient(DataGridView.MousePosition))) { if (DataGridView.MouseButtons.HasFlag(MouseButtons.Left)) { state = ComboBoxState.Pressed; legacyState = ButtonState.Pushed; } else { state = ComboBoxState.Hot; } } } Rectangle comboBounds = cellBounds; comboBounds.Width--; if (((DropDownColumnBase)OwningColumn).BufferedPaintingSupported) { GroupedComboBox.DrawComboBox(graphics, comboBounds, state); } else { DropDownControlBase.DrawLegacyComboBox(graphics, comboBounds, DropDownControlBase.GetComboButtonBounds(comboBounds), cellStyle.BackColor, legacyState); } } }
private void AddJournal_Load(object sender, EventArgs e) { //cmDebitAccount.DataSource = new DAO().GetAccountNames(); //cmCreditAccount.DataSource = new DAO().GetAccountNames(); GroupedComboBox groupedCombo = new GroupedComboBox(); //groupedCombo.ValueMember = "Value"; //groupedCombo.DisplayMember = "Display"; //groupedCombo.GroupMember = "Group"; //cmDebitAccount.DataSource = new DAO().GetAccountNames(); //cmDebitAccount.DisplayMember = "AccountName"; //cmDebitAccount.ValueMember = "AccountId"; //cmDebitAccount.GroupMember = "Group"; //cmDebitAccount.DataSource = new BindingSource(groupedItems, String.Empty); cmDebitAccount.ValueMember = "AccountId"; cmDebitAccount.DisplayMember = "AccountName"; cmDebitAccount.GroupMember = "AccountType"; cmDebitAccount.DataSource = new BindingSource(new DAO().GetfullAccountNames(), String.Empty); cmDebitAccount.SelectedIndex = -1; cmCreditAccount.ValueMember = "AccountId"; cmCreditAccount.DisplayMember = "AccountName"; cmCreditAccount.GroupMember = "AccountType"; cmCreditAccount.DataSource = new BindingSource(new DAO().GetfullAccountNames(), String.Empty); //cmDebitAccount.SelectedIndex = -1; //cmCreditAccount.DataSource = new DAO().GetAccountNames(); //cmCreditAccount.DisplayMember = "AccountName"; //cmCreditAccount.ValueMember = "AccountId"; //cmCreditAccount.SelectedIndex = -1; txtJournalId.Text = JournalId; }
public Row(GroupedComboBox projectBox, TextBox timeBox, TextBox descriptionBox, Label deleteButton) { this.ProjectBox = projectBox; this.ProjectBox.DisplayMember = "DisplayName"; this.ProjectBox.ValueMember = "ProjectID"; this.ProjectBox.GroupMember = "Department"; this.ProjectBox.AutoCompleteMode = AutoCompleteMode.Append; this.ProjectBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; this.ProjectBox.TextChanged += new EventHandler(ProjectBox_TextChanged); this.TimeBox = timeBox; this.TimeBox.Tag = true; // prevent TextChanged event this.TimeBox.Text = ""; this.TimeBox.Enter += new EventHandler(TextBox_Enter); this.TimeBox.TextChanged += new EventHandler(TimeBox_TextChanged); this.DescriptionBox = descriptionBox; this.DescriptionBox.Enter += new EventHandler(TextBox_Enter); this.DescriptionBox.TextChanged += new EventHandler(DescriptionBox_TextChanged); this.DeleteButton = deleteButton; this.DeleteButton.Click += new EventHandler(DeleteButton_Click); }