You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
2.0 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
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.Shapes;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// UserInformation.xaml 的交互逻辑
/// </summary>
public partial class UserInformation : Window
{
DataTable dataTable = new DataTable();
public UserInformation()
{
InitializeComponent();
//DataTable dataTable = new DataTable();
dataTable.Columns.Add("Machine",Type.GetType("System.String"));
dataTable.Columns.Add("Information", Type.GetType("System.String"));
dataTable.Columns.Add("Code", Type.GetType("System.String"));
dataTable.Columns.Add("ID", Type.GetType("System.Int32"));
dataTable.Rows.Add(new object[] { "1", "a","423","12"});
dataTable.Rows.Add(new object[] { "2", "b" ,"345","122"});
dataTable.Rows.Add(new object[] { "3", "c" ,"345","32"});
dataTable.Rows.Add(new object[] { "1", "a", "423", "1232" });
dataTable.Rows.Add(new object[] { "2", "b", "345", "1222" });
dataTable.Rows.Add(new object[] { "3", "c", "345", "325" });
Griddata.ItemsSource = dataTable.DefaultView;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
DataRowView datarow = (DataRowView)button.Tag;
var y= datarow.Row.Field<int>("ID");
DataRow erwqer = dataTable.Select("ID='" + y + "'").First();
erwqer.Delete();
Griddata.ItemsSource = dataTable.DefaultView;
if (dataTable.Rows.Count == 0) { this.Close(); }
}
}
}