一、插件添加方法
1. 添加工程引用
引用->右键添加引用->浏览->选择准备好的System.Windows.Forms.Ribbon.dll文件
2. 工具箱内添加控件
工具箱右键选择项->.NEF Framework组件->浏览->选择准备好的SourceGrid.dll文件
二、相关用法备份
1.设置表大小: Grid_Minerals.Redim(行数, 列数);
2.表头相关:
创建:SourceGrid.Cells.ColumnHeader head1 =new SourceGrid.Cells.ColumnHeader("表头名称");
Grid_Minerals[0, 0] = head1;
head1.AutomaticSortEnabled = false;
表头字体,对齐方式:
SourceGrid.Cells.Views.ColumnHeader boldHeader = new SourceGrid.Cells.Views.ColumnHeader();
boldHeader.Font = new Font("Microsoft YaHei UI", 11, FontStyle.Bold);
boldHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
Grid_Minerals[0, 0].View = boldHeader;
3.总体编辑:
Grid_Minerals.Rows.SetHeight(行数, 高度);
Grid_Minerals.Columns.SetWidth(列数, 宽度);
Grid_Minerals.Selection.EnableMultiSelection = false; 不可同时选中多个
Grid_Minerals.AutoStretchColumnsToFitWidth = true; 自适应宽度
Grid_Minerals.Columns[0].Width = 20; 某一列宽度
Grid_Minerals.FixedRows = n;// 第n个行不可以滚动(表头不参与滚动)
Grid_Attributes[0, 0].ColumnSpan = 2; //从[0,0]开始合并2个单元格
Grid_Attributes.AutomaticSortEnabled = false; //不可自动排序
Grid_Attributes.Refresh(); //表刷新
启动时默认无选中:Grid_Attributes.Selection.FocusStyle = SourceGrid.FocusStyle.None;
创建单元格: Grid_Attributes[1, 0] = new SourceGrid.Cells.Cell("名称", typeof(数据类型));
设置单元格相关参数:
SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
view.BackColor = Color.LightGray;
Grid_Attributes[0, 0].View = view;
单元格添加事件:
SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
clickEvent.Click += new EventHandler(clickEvent_Click);
Grid_Attributes[2,1].AddController(clickEvent);
SourceGrid.Cells.Controllers.CustomEvents ValueChangedEvent = new SourceGrid.Cells.Controllers.CustomEvents();
ValueChangedEvent.ValueChanged += new EventHandler(Event_ValueChanged);
Grid_FroupId[i, 0].AddController(ValueChangedEvent);
单元格焦点显示(但不是处于选中状态)
SourceGrid.Position po = new SourceGrid.Position(1, 0);
Grid_Attributes.Selection.Focus(po, true);
单元格焦点显示(并且处于选中状态)
SourceGrid.Position po = new SourceGrid.Position(1, 0);
Grid_Attributes[1, 0].Grid.Select();
Grid_Attributes.Selection.Focus(po, true);
单元格不可选中:Grid_Attributes[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
添加Combobox类型单元格:
List<string> ss = new List<string>();
foreach (DataRow item in dt.Rows)
{
填充表ss;
}
SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
GroupIdCBBox.StandardValues = ss;
GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick| SourceGrid.EditableMode.Focus;//点击显示下拉列表
m_Attributes.Grid_Attributes[9, 1] = new SourceGrid.Cells.Cell("显示的内容", GroupIdCBBox);
m_ComboboxText.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
相关资料引用(感谢相关大神):