อ่านในภาษาอังกฤษ แก้ไข

แชร์ผ่าน


DrawListViewSubItemEventArgs.DrawDefault Property

Definition

Gets or sets a value indicating whether the ListViewItem.ListViewSubItem should be drawn by the operating system instead of owner-drawn.

C#
public bool DrawDefault { get; set; }

Property Value

true if the subitem should be drawn by the operating system; otherwise, false. The default is false.

Examples

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the ListView.DrawSubItem event. This report helps you to learn when the event occurs and can assist you in debugging.

To run the example code, paste it into a project that contains an instance of type ListView named ListView1. Then ensure that the event handler is associated with the ListView.DrawSubItem event.

C#
private void ListView1_DrawSubItem(Object sender, DrawListViewSubItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Bounds", e.Bounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SubItem", e.SubItem );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Header", e.Header );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ItemState", e.ItemState );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "DrawSubItem Event" );
}

Remarks

Use this property when handling the ListView.DrawSubItem event for subitems that you do not want to customize. If you set this property to true, the subitem will be drawn normally using the current values of the ListViewItem.ListViewSubItem.BackColor, ListViewItem.ListViewSubItem.ForeColor, and ListViewItem.ListViewSubItem.Font properties

หมายเหตุ

The UseItemStyleForSubItems property of the parent ListViewItem must be set to false to prevent the ListViewItem.BackColor value of the parent item from overriding the subitem value.

Applies to

ผลิตภัณฑ์ เวอร์ชัน
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also