datagridview 列宽问题
我在datagridview设置 allowusertoresizecolums=true;
怎么用户不能调整列宽.
另外我设置了datagridview每列宽后.还希望用户能调整列宽,怎么设置啊.
------解决方案--------------------//允许用户调整
private void LockCurrentColumns_CheckedChanged(object sender, EventArgs e)
{
this.GridViewAll.AllowUserToOrderColumns = !this.LockCurrentColumns.Checked;
this.GridViewAll.AllowUserToResizeColumns = !this.LockCurrentColumns.Checked;
}
//调整后保存
private void SaveCurrentProperty_Click(object sender, EventArgs e)
{
int i;
string strWidth = " ";
int count = this.GridViewAll.Columns.Count;
if (count > 0)
{
for (i = 0; i < count - 1; i++)
strWidth += this.GridViewAll.Columns[i].Width.ToString() + ", ";
strWidth += this.GridViewAll.Columns[count - 1].Width.ToString();
cfgFile.WritePrivateProfile( "DataView ", "ColumnWidth ", strWidth, IniFileName);
}
}
我就是这么写的,如果你的不行,就看看你的DataGridView设置,包括每列的设置吧。