111,126
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void gridControl1_Click(object sender, EventArgs e)
{
}
private DataTable CreateDataTable()
{
DataTable dt = new DataTable();
//如果是从数据库中的原始数据,就把设为:IsOriginal=true;
DataColumn dc = new DataColumn("IsOriginal", typeof(bool));
dt.Columns.Add(dc);
bindingSource1.DataSource = dt;
gridControl1.DataSource = bindingSource1;
gridView1.BestFitColumns();
}
private void Form1_Load(object sender, EventArgs e)
{
CreateDataTable();
}
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
DataRow dRow = gridView1.GetDataRow(gridView1.FocusedRowHandle);
if (dRow != null)
{
if (Convert.ToBoolean(dRow["IsOriginal"]) == true)
{
MessageBox.Show("数据库中的原始数据禁止修改");
bindingSource1.CancelEdit();
gridView1.RefreshData();
}
}
}
}
}