【发布时间】:2018-08-30 01:49:54
【问题描述】:
我是 LiteDB 的新手,但在使用繁琐的 CSV 文件后,它似乎非常适合我的应用程序,但我无法在 Windows 窗体 DataGridView 中显示数据。
我的 LiteDB 数据库在存储数据方面工作正常,但需要帮助来显示数据。
这是我的 POCO 和用户数据存储方法:
public class Preset
{
[BsonId]
public int _id { get; set; }
public string Name { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Z { get; set; }
public int Foam { get; set; }
}
public void DataBase()
{
using (var db = new LiteDatabase(DB))
{
var col = db.GetCollection<Preset>("presets");
var preset = new Preset
{
Name = CustomPresetName.Text,
X = Int16.Parse(CustomX.Text),
Y = Int16.Parse(CustomY.Text),
Z = Int16.Parse(CustomZ.Text),
Foam = Int16.Parse(Foam.Text)
};
col.Insert(preset);
}
}
我只是尝试将 DataGridView 与对象作为数据源链接,但它不显示数据,只显示标题。我也上网浏览过类似的问题或答案,但似乎没有受到任何影响。
感谢任何有关让数据显示在 DataGridView 中的帮助。
【问题讨论】:
标签: c# datagridview windows-forms-designer litedb