wpf 如何遍历listview
1个回答
展开全部
XAML代码:
<ListView Name="listview1" Margin="230,0,294,57" VerticalAlignment="Bottom" Height="100" MouseLeftButtonDown="ListView_MouseLeftButtonDown">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
<CheckBox Name="check1"/>
<CheckBox Name="check2"/>
</ListView>
事件代码:
private void ListView_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if(listview1.Items[0].GetType().ToString()=="System.Windows.Controls.CheckBox")
{
MessageBox.Show(listview1.Items[0].GetType().ToString());
listview1.Items.Remove(listview1.Items[0]);
}
}
<ListView Name="listview1" Margin="230,0,294,57" VerticalAlignment="Bottom" Height="100" MouseLeftButtonDown="ListView_MouseLeftButtonDown">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
<CheckBox Name="check1"/>
<CheckBox Name="check2"/>
</ListView>
事件代码:
private void ListView_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if(listview1.Items[0].GetType().ToString()=="System.Windows.Controls.CheckBox")
{
MessageBox.Show(listview1.Items[0].GetType().ToString());
listview1.Items.Remove(listview1.Items[0]);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询