【发布时间】:2015-05-24 13:26:59
【问题描述】:
我有 DataGrid 和 CheckBox 列。我希望通过按一个按钮来删除所有选中的行。 (我有删除的特殊功能)
我搜索如何做到这一点foreach 循环,我发现了这个 -
private void delete_Click(object sender, RoutedEventArgs e)
{
foreach (DataGridViewRow row in gridDepartment.Rows)
{
if (Convert.ToBoolean(row.Cells[CheckBoxColumn1.Name].Value) == true)
{
// get row number
remove(list.ElementAt(rowNumber));
}
}
}
但是,DataGridViewRow、Rows、CheckBoxColumn1、Cells 和 Value 仍然是黑色的。
我尝试添加using System.Windows.Forms; 和DataGridViewRow chenge 他的颜色,但所有MessageBox 和UserControl 显示错误:
MessageBox 是 System.Windows.MessageBox 之间的模糊引用 和 System.Windows.Forms.MessageBox
这些是我的参考:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
我能做什么?谢谢。
【问题讨论】: