看来,由于未知原因,我现在无法编辑DataGridView中的任何内容。 DGV的ReadOnly属性值为false,除1之外的所有列都将ReadOnly属性也设置为false。无法编辑DataGridView中的值(使用BindingList)
我开始认为这可能是由于我尝试添加到我的一个类中的一个特殊值,一个我只想在类中修改,但仍然只读给公众。我不认为该值与别的搞乱,但没有少,这里是我的代码的相关部分:
private void loaderWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
loadingBar.Value = e.ProgressPercentage;
if (e.UserState != null)
{
savefiles.Add((SaveFile)e.UserState);
}
}
凡savefiles是的BindingList,并在SAVEFILE是我的课:
public class SaveFile
{
private string d_directory;
private int d_weirdnumber;
private bool d_isautosave;
private string d_fullname;
private string d_datatype;
private string d_owner;
private bool d_isquicksave;
private string d_title;
private string d_gametime;
public SaveFile() { }
public SaveFile(string directory, int weirdnumber, bool isautosave, string fullname, string datatype, string owner, bool isquicksave, string title)
{
d_directory = directory;
d_weirdnumber = weirdnumber;
d_isautosave = isautosave;
d_fullname = fullname;
d_datatype = datatype;
d_owner = owner;
d_isquicksave = isquicksave;
d_title = title;
}
public string Gametime
{
get { return d_gametime; }
}
public string Datatype
{
get { return d_datatype; }
set { d_datatype = value; }
}
public string Title
{
get { return d_title; }
set { d_title = value; }
}
public bool IsQuickSave
{
get { return d_isquicksave; }
set { d_isquicksave = value; }
}
public bool IsAutoSave
{
get { return d_isautosave; }
set { d_isautosave = value; }
}
public string Directory
{
get { return d_directory; }
set { d_directory = value; }
}
public string FullName
{
get { return d_fullname; }
set
{
d_fullname = value;
string[] split = value.Split(new char[]{'-'});
foreach (string str in split)
{
if (System.Text.RegularExpressions.Regex.IsMatch(str, "^\\d\\d:\\d\\d:\\d\\d$"))
{
d_gametime = str;
}
}
}
}
public int Weirdnumber
{
get { return d_weirdnumber; }
set { d_weirdnumber = value; }
}
public string Owner
{
get { return d_owner; }
set { d_owner = value; }
}
}
游戏时间是我前面提到的特殊属性。它没有设置功能,但根据this,我应该清楚,对吧?
任何人都可以告诉我为什么我可能无法编辑任何DGV单元?
编辑:我刚刚发现不设置的AutoGenerateColumns为false,让我重新编辑,但我仍然不知道为什么。
我刚刚遇到同样的问题。教训:不要相信VS Designer(VS2012) – nf313743 2013-06-07 10:32:00