ListControlConvertEventArgs.ListItem 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取数据源项。
public:
property System::Object ^ ListItem { System::Object ^ get(); };
public object ListItem { get; }
public object? ListItem { get; }
member this.ListItem : obj
Public ReadOnly Property ListItem As Object
属性值
表示 Object 数据源中的项。
示例
下面的代码示例演示了此成员的使用。 在此示例中,事件处理程序报告事件的发生情况 ListControl.Format 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑替换MessageBox.ShowConsole.WriteLine或将消息追加到多行TextBox。
若要运行示例代码,请将其粘贴到包含继承自 ListControl的类型实例的项目(如 ComboBox 或 ListBox)。 然后为实例 ListControl1 命名,并确保事件处理程序与 ListControl.Format 该事件相关联。
private void ListControl1_Format(Object sender, ListControlConvertEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ListItem", e.ListItem );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Value", e.Value );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Format Event" );
}
Private Sub ListControl1_Format(sender as Object, e as ListControlConvertEventArgs) _
Handles ListControl1.Format
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "ListItem", e.ListItem)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Value", e.Value)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"Format Event")
End Sub