dataGridView 中的值在绑定出来后能在 页面显示前 修改 要列 的值 啊?
dataGridView1的列 审核 绑定到 表 的check列的
当check值是 1 时 在dataGridView显示审核,
0 显示未审核 。
dataGridView1的列 审核 绑定到 表 的check列的
当check值是 1 时 在dataGridView显示审核,
0 显示未审核 。
解决方案 »
- 求截取价格正则表达式
- Winform中Excel导入到指定的表中
- 请教关于DropDownList的问题
- 请问 C# 的 DLL 返回一个 event 给 VB6 ,DLL怎么写?
- 新手问: 我想用XmlTextReader 读一个XML的一个节点到TextBox.text中。。。
- 关于url Encoding的问题
- 怎样判断pictureBox中是否存在图片啊?
- 我有个登录form有个MainForm想在MainForm打开前,先打开登陆Form,但是我如何把登陆后的信息传给MainForm
- 读取excel数据的问题
- 在线等,急~~~~~~小弟遇到一个关于时间查询的问题,很是不解,希望高人解答,万分感谢~~~~
- Build 和 Rebuild有什么区别?谢谢了!
- C#对视频开发的问题,急求高手回答
dataGridView1.Columns.Insert(0, new DataGridViewCheckBoxColumn());添加的checkBox啊我用
(bool)dataGridView1.Rows[e.RowIndex].Cells[0].Value
可以取得checkbox的值啊
我在自己机器上测试可以的如果需要 我可以给你源程序 你加我MSN把 [email protected]
dataGridView1的列"审核" 绑定到 表"user" 的"userState"列
当表里面"userState"值是 1 时 在dataGridView的"审核"列显示"审核",不显示表里的"1",
0 显示"未审核",不显示表里的值"0" 。
这个是在显示dataGridView前的单元格式化的时候发生的 要知道这个关于事件更多的
你去查下帮助 比我说的好
前面那个回复是你上个帖子的 我回的时候你已经结贴了
其实用你自己添加的CHECKBOX是可以访问到它的值的 可能你的代码那里出了错
{
//if (dataGridView1.Rows[0].Cells["Column7"].Value.ToString() == "1")
//用它提示:未将对象引用设置到对象的实例。
if(ds.Tables[0].Rows[0]["UserState"].ToString()=="1")
//用它无法找到表0
ds
{
MessageBox.Show("ddf");
}
}
判断那个?
namespace admin
{
public partial class text : Form
{
public text()
{
InitializeComponent();
} private void text_Load(object sender, EventArgs e)
{
ShowBind();
}
public void ShowBind()
{
DataSet ds = new DataSet();
dataGridView1.AutoGenerateColumns = false;
dataGridView1.AllowUserToAddRows = false; ds = SqlBase.Getds("select *from db_user");
dataGridView1.DataSource = ds;
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.DataMember = ds.Tables[0].TableName;
}
else
{
MessageBox.Show("没有相关数据!");
}
} private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridView1.Rows[0].Cells["Column2"].Value.ToString() == "1")
//用它提示:未将对象引用设置到对象的实例。
//if(ds.Tables[0].Rows[0]["UserState"].ToString()=="1")
//用它无法找到表0
{
MessageBox.Show("ddf");
}
}
}
}
if (e.ColumnIndex == this.dataGridView1.Columns["你要判断的列"].Index)
{
if (dataGridView1.Rows[e.RowIndex].Cells["你要判断的列"].Value.ToString() == "1")
{
//处理
}
}
这样好点 如果还出错你试下重新建个工程
另外 我以前Cells[""]里面用的中文列名,也出过 未将对象引用设置到对象的实例 的错,
可能是对中文支持不是很好
要是用列名不行的话 直接用列的Index 比如第1列用0;
要是还有错,,,,我就不知道了
我也是新手