Data binding 自定义DataGridViewColumn(WinForms)中多个文件的自定义绑定
我有一个关于自定义DataGridViewColumn的数据绑定(多个属性)的问题。 下面是我拥有的控件的模式,我需要使其与DataGridView数据源绑定。有没有关于讨论这个问题的文章的想法或链接 控件Data binding 自定义DataGridViewColumn(WinForms)中多个文件的自定义绑定,data-binding,datagridview,datagridviewcolumn,Data Binding,Datagridview,Datagridviewcolumn,我有一个关于自定义DataGridViewColumn的数据绑定(多个属性)的问题。 下面是我拥有的控件的模式,我需要使其与DataGridView数据源绑定。有没有关于讨论这个问题的文章的想法或链接 控件 图形控件(自定义):显示在 custrom DataGridView列。有 属性,如“开始日期”, “EndDate”,Windows图表控件, 它本身是可装订的 自定义单元格(DataGridViewCustomCell继承 从DataGridViewCell)保存 图形控件和一些进程
- 图形控件(自定义):显示在 custrom DataGridView列。有 属性,如“开始日期”, “EndDate”,Windows图表控件, 它本身是可装订的
- 自定义单元格(DataGridViewCustomCell继承 从DataGridViewCell)保存 图形控件和一些进程 事件(例如,OneNet事件, 将焦点传递给自定义图形 用于拖放类型的列 事件等)
- 自定义列(DataGridViewCustomColumn) 从DataGridViewColumn继承) 定义单元模板类型的: CellTemplate=新 DataGridViewCustomCell();也是一个 数据绑定的主要选择
- 要在其他DataGridView列中显示的主表
- 图表表-通过父子关系与主表相关。保存图形数据
- 通过父子关系与图形表相关的图表表。保存win form图表的数据,win form图表是我的图形控件的一部分
编辑:您还可以在填充datagridview的sql中使用联接。谢谢您的回答。我的数据源不是SQL数据源,事实上,我所说的是针对win forms的datagridview(我不确定这是否清楚) 由于我在任何论坛上都没有得到回答,我想,我会为那些可能有类似问题的人和可能的批评概述我提出的解决方案。:-) (著名的MS示例中也解释了步骤1-2) 1.创建从DataGridViewColumn和DataGridViewCell继承的自己的类,设置列模板; 2.创建“自定义编辑”控件
public partial class MyCell : DataGridViewCell
{
protected override void Paint(...)
{...} // draws control
// receives data item as a value
// in my case I have to custom-draw entire control in this fnc.
public override void InitializeEditingControl(...)
{...} // initialize control editing
// override some other properties
public override Type EditType {
get{
return typeof(MyEditControl);
}
}
public override Type ValueType{
get{
return typeof(MyItem);
}
}
}
自定义列:
public partial class MyColumn : DataGridViewColumn
{
public MyColumn(){ ...
CellTemplate = new MyCell();
}
}
编辑控件:
public partial class MyEditControl : UserControl, IDataGridViewEditingControl
{... // implements IDataGridViewEditingControl
// value is our data item
}
数据项,则数据源成为列表
public class MyItem:Object{
...
[XmlIgnore] // I need it because I do serialization
public MyItem Self {
get {
return this;
}
}
}