/// <summary> /// 编辑信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, RoutedEventArgs e) { //获取鼠标选择的索引 int num = dgUsers.SelectedIndex; if (num < 0) { MessageBox.Show("请选择要修改的行!"); } else { //获取选中行 RecordData user = (RecordData)dgUsers.SelectedValue; //打开编辑窗口 EditRecordPage editRecord = new EditRecordPage(); editRecord.isAdd = false; //设置编号不能编辑 editRecord.txtID.IsReadOnly = true; //绑定数据 editRecord.gridUser.DataContext = user; //显示窗口 editRecord.ShowDialog(); } }
// 添加信息 private void btnAdd_Click(object sender, RoutedEventArgs e) { // DispatcherTimer timer = new DispatcherTimer(); EditRecordPage editUser = new EditRecordPage(); editUser.isAdd = true; editUser.ShowDialog(); //加载数据 LoadData(); }