protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { base.OnDrawColumnHeader(e); if (e.ColumnIndex == 0) { var headerCheckBox = new CheckBox {Text = "", Visible = true}; SuspendLayout(); e.DrawBackground(); headerCheckBox.BackColor = Color.Transparent; headerCheckBox.UseVisualStyleBackColor = true; headerCheckBox.BackgroundImage = Resources.ListViewHeaderCheckboxBackgroud; headerCheckBox.SetBounds(e.Bounds.X, e.Bounds.Y, headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)). Width, headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)). Height); headerCheckBox.Size = new Size(headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1, e.Bounds.Height); headerCheckBox.Location = new Point(4, 0); Controls.Add(headerCheckBox); headerCheckBox.Show(); headerCheckBox.BringToFront(); e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left); headerCheckBox.CheckedChanged += OnHeaderCheckboxCheckedChanged; ResumeLayout(true); } else { e.DrawDefault = true; } }
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) { base.OnDrawColumnHeader(e); e.DrawBackground(); e.DrawText(); //e.BackColor = System.Drawing.Color.AliceBlue; }
void SortableListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { bool fSorted = (this._sortColumn == e.ColumnIndex); if (fSorted) { e.DrawBackground(); e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); //如果是排序,并且图片不为空,那么绘制图标 if (fSorted && (_imageAscending != null) && (this._imageDescending != null)) { Point ptImage = new Point(e.Bounds.Left + (int)e.Graphics.MeasureString(e.Header.Text + "XY", e.Font).Width, (e.Bounds.Top + e.Bounds.Bottom - _imageAscending.Height) / 2); e.Graphics.DrawImage((this._sortOrder > 0) ? _imageAscending : _imageDescending, ptImage); } this.Refresh(); } else { e.DrawDefault = true; } }
/// <summary> /// Owner draw requires drawing the column header as well as the list items. See LT-7007. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void currentList_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawBackground(); e.DrawText(); }
private void ListView_EnabledEvents_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(Brushes.GreenYellow, e.Bounds); e.DrawText(); e.DrawDefault = true; }
private void DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawDefault = true; e.DrawBackground(); e.DrawText(); }
private void ActionListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(Brushes.White, e.Bounds); //采用特定颜色绘制标题列 e.DrawText(); }
private void listView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawBackground(); e.DrawText(); }
//private void editToolStripMenuItem_Click(object sender, EventArgs e) //{ // if (lvwTaskOfTheDay.SelectedItems.Count > 0) // { // foreach (ListViewItem lvi in lvwTaskOfTheDay.SelectedItems) // { // strRecurringID = lvi.Tag.ToString(); // strRecurringName = lvi.Text; // strRecurringDes = lvi.SubItems[1].Text; // strRecurringDate = lvi.SubItems[2].Text; // strRecurringTime = lvi.SubItems[3].Text; // strRecurringRepeat = lvi.SubItems[4].Text; // frmNewRecurring.strFlag = "Edit"; // frmNewRecurring er = new frmNewRecurring(); // er.ShowDialog(); // LoadListView(); // } // } // else // { // MessageBox.Show("No item selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} private void lvwTaskOfTheDay_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(Brushes.LightGoldenrodYellow, e.Bounds); e.DrawText(); }
void ListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.Graphics.FillRectangle(Brushes.DimGray, e.Bounds); e.DrawText(); }
private void lvServerBrowser_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawText(); }