【发布时间】:2010-12-12 03:14:01
【问题描述】:
似乎由于未知原因,我现在无法在我的 DataGridView 中编辑任何内容。 DGV 的 ReadOnly 属性值为 false,除一列之外的所有列的 ReadOnly 属性也都设置为 false。
我开始认为这可能是由于我尝试将一个特殊值添加到我的一个类中,我只想在类中进行修改,但仍然只对公众阅读。我不认为该值会影响其他任何东西,但无论如何,这里是我的代码的相关部分:
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; }
}
}
Gametime 是我之前提到的那个特殊属性。它没有设置功能,但按照this的说法,我应该是清楚的吧?
谁能告诉我为什么我可能无法编辑任何 DGV 单元格?
编辑:我刚刚发现 not 将 AutoGenerateColumns 设置为 false 允许我再次编辑,但我仍然不知道为什么。
【问题讨论】:
标签: c# .net-3.5 datagridview properties