为什么我的单元格值没有被截断?
问题描述:
这里就是我想在我的WinForms DataGridView中要做到:为什么我的单元格值没有被截断?
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex > 1)
{
string tmpValue = Convert.ToString(dataGridView1[e.ColumnIndex, e.RowIndex].Value);
if (tmpValue.Length >= 3)
{
//At thsi point, I'm 100% sure that tmpValue has "253" as it's value.
dataGridView1[e.ColumnIndex, e.RowIndex].Value = tmpValue.Substring(0, 2);
}
}
}
然而,该值没有改变细胞我离开的。
如果我输入的单元258和离开,它应该有25
有什么建议?
答
也许是:dataGridView1.DataBind()
该方法不存在。 – 2011-05-16 12:36:25
我刚刚检查过,我必须离开牢房,回到它,然后再次离开**然后**按预期工作。有任何想法吗? – 2011-05-16 12:41:09
也许他们是指'无效'? – 2011-05-16 12:41:11