首页 > 代码库 > LSGO类库使用方法备忘——FlexCell
LSGO类库使用方法备忘——FlexCell
相关类介绍:
1.LSGOUIGridEntity 用于配置FlexCell表格各种参数的实体
有已下三种便捷的方法,均返回已经配置好参数的LSGOUIGridEntity 类的实体
GetNormalGridEntity() 得到普通类型的MisUIGridEntity.
GetDark_LightBlueGridEntity() 得到深蓝-浅蓝格调的GridEntity.
GetYellow_WhiteGridEntity() 得到黄-白格调的GridEntity.
示例:LSGOUIGridEntity gridEntity = (new LSGOUIGridEntity()).GetYellow_WhiteGridEntity();
2.LSGOUIGrid FlexCell表格控件类,提供初始化,操纵表格的各种静态方法
Init:初始化FlexCell表格控件的属性及样式
public static void Init(Grid Grid, LSGOUIGridEntity GridEntity)
示例:LSGOUIGrid.Init(grid, gridEntity);
InitHeader 初始化表格的列名(通过字符串链表/ILSGODataFieldCollection)
public static void InitHeader(Grid Grid, List<string> FieldList)
public static void InitHeader(Grid Grid, ILSGODataFieldCollection FieldCollection)
示例:
List<string> pListStr = new List<string> { "版本属性", "版本信息" }; //创建字符串链表
LSGOUIGrid.InitHeader(grid, pListStr); //初始化表格的列名
将信息填入FlexCell表格中
FillDataToGrid()的各种重载方法
public static void InsertDataToGrid(List<string> valueList, Grid Grid) //自定义方法
示例:LSGOUIGrid.InsertDataToGrid(new List<string> { "用户名", "" }, grid_Verson);
使用方法示例:
整体思路分四步:
实例化 LSGOUIGridEntity
调用LSGOUIGrid.Init()初始化表格
调用LSGOUIGrid.InitHeader()初始化列名
填充内容FillDataToGrid()/InsertDataToGrid()
示例1:
/// <summary>
/// 初始化版本信息表格
/// </summary>
/// <param name="grid"></param>
private void InitGrid_Verson(Grid grid)
{
LSGOUIGridEntity gridEntity = (new LSGOUIGridEntity()).GetYellow_WhiteGridEntity();
LSGOUIGrid.Init(grid, gridEntity);
grid.ExtendLastCol = true; //自动延长最后一列
List<string> pListStr = new List<string> { "版本属性", "版本信息" };
LSGOUIGrid.InitHeader(grid, pListStr);
LSGOUIGrid.InsertDataToGrid(new List<string> { "用户名", "" }, grid_Verson);
LSGOUIGrid.InsertDataToGrid(new List<string> { "版本名", "" }, grid_Verson);
LSGOUIGrid.InsertDataToGrid(new List<string> { "父版本名", "" }, grid_Verson);
LSGOUIGrid.InsertDataToGrid(new List<string> { "创建时间", "" }, grid_Verson);
LSGOUIGrid.InsertDataToGrid(new List<string> { "最后修改时间", "" }, grid_Verson);
LSGOUIGrid.InsertDataToGrid(new List<string> { "版本描述", "" }, grid_Verson);
grid.Column(0).AutoFit();
}
常用属性
AutoRedraw 自动重绘
ExtendLastCol 自动延长最后一列
Locked 只读
特别的,如果需要对表格中的某些元素/行/列设置只读,其余不设,偷懒的方法是不行的。需要对表格整体设置非只读,然后对只读元素依次设置,例如:
//取消教师评价列的只读设置
grid_StudentScore.Locked = false;
grid_StudentScore.Column(0).Locked = true ;
grid_StudentScore.Column(1).Locked = true;
grid_StudentScore.Column(2).Locked = true;
grid_StudentScore.Column(3).Locked = true;
grid_StudentScore.Column(4).Locked = true;
本文出自 “随煜而安” 博客,转载请与作者联系!
LSGO类库使用方法备忘——FlexCell