在DataGridView中,事情很正常,但是我想学习如何继承一个表,并对从SQLite数据库中获取的每个数据项进行重构?
我(System.Windows.Forms.Table)
使用Visual Studio 2013设计器设计了一个表,这几乎是一个拖放式设计。
该表有两列,最左边一列显示从SQLite数据库获取的数据,它还有一个子表(System.Windows.Forms.Table)
有两个行(表行),其中每一行(表行)都有一个textField,它们实际上显示给不同的数据库行(此是数据库行)值。
右侧有一些按钮可触发少量事件。
外观如下:http : //i.stack.imgur.com/Q8Lfd.png
现在我的问题是,在这种环境下,我如何继承此表设计并创建多个实例,foreach
数据行来自其SQLite数据库文件?
演示:这是我想要实现的目标的快速演示。
假设名为“列表”的数据库表有四个项目,那么此应用程序将创建该表的四个实例(Windows表单表),将所有数据插入到表(Windows表单表)的适当字段中,然后在“ Form1“表单,看起来像这样[在photoshop上完成的;)]
请通过给出您的想法和参考文献来指导我正确的方法
It's been a while since I worked in WinForms, but the concept is similar in all of the DotNet UI methodologies based upon the question from GER on the original post.
If you define a UserControl that renders the data to look like a single instance of what you have in your photo-shopped item, you can then reuse that control several times.
In your main form, you can now do a loop to add this control as many times as you need programmatically (psuedo code follows at the end).
You will also need a TableLayoutPanel (https://msdn.microsoft.com/en-us/library/vstudio/system.windows.forms.tablelayoutpanel%28v=vs.100%29.aspx) or similar for your primary form to serve as the layoutPanel.
foreach(DataTable table in Tables)
{
MyChildControl childControl = new MyChildControl();
childControl.Confiure(table); // Sets the data for the control.
layoutPanel.Controls.Add(childControl); // This call varies by UI method and what layoutPanel you are using
}
警告:我对WinForms不够记得,无法记住如何在控件上设置网格行/列设置。如果适合您,您就可以对此进行一些研究。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句