WPF的表格控件 FlexGrid设置行的高度自适应

行高自适应通过内容长度设置的,有列宽自适应方法,行高的试过不行,于是用内容长度控制行高

private void FlexGrid_LoadedRows_RowIndex(object sender, EventArgs e)

{

ViewHelper.SetRowIndexNoPage(CfgReviewItem);

//CfgReviewItem.Rows0.Height;

// CfgReviewItem.AutoSizeRow(1,0);

if (CfgReviewItem == null) return;

if (CfgReviewItem.Rows.Count > 0)

{

int i = 0;

int CustomerRequestLength = 0;

int InPlantCapacityLength = 0;

int SchemeDescribeLength = 0;

bool istrue = true;

foreach (var row in CfgReviewItem.Rows)

{

var model = row.DataItem as HardBCReviewItemModel;

if (model == null) continue;

//获取长度

string CustomerRequest = model.CustomerRequest;

string InPlantCapacity = model.InPlantCapacity;

string SchemeDescribe = model.InPlantCapacity;

istrue = string.IsNullOrEmpty(CustomerRequest);

CustomerRequestLength = istrue ? 0 : CustomerRequest.Length;

istrue = string.IsNullOrEmpty(InPlantCapacity);

InPlantCapacityLength = istrue ? 0 : InPlantCapacity.Length;

istrue = string.IsNullOrEmpty(SchemeDescribe);

SchemeDescribeLength = istrue ? 0 : SchemeDescribe.Length;

if (CustomerRequestLength >= InPlantCapacityLength&& CustomerRequestLength >= SchemeDescribeLength) {

setHeight(CustomerRequestLength, i);

i++;

continue;

}else

if (InPlantCapacityLength >= CustomerRequestLength && InPlantCapacityLength >= SchemeDescribeLength)

{

setHeight(InPlantCapacityLength, i);

i++;

continue;

} else

if (SchemeDescribeLength >= InPlantCapacityLength && SchemeDescribeLength >= CustomerRequestLength)

{

setHeight(SchemeDescribeLength, i);

i++;

continue;

}

}

}

// CfgReviewItem.Rows0.Height = 200;

// 列宽自适应 CfgReviewItem.AutoSizeColumns(0, CfgReviewItem.Columns.Count, 0);

}

public void setHeight(int height,int i) {

if (height < 100)

{

CfgReviewItem.Rowsi.Height = 50;

}

else if (height > 100 && height < 200)

{

CfgReviewItem.Rowsi.Height = 100;

}

else if (height > 200)

{

CfgReviewItem.Rowsi.Height = 200;

}

}

相关推荐
Xin_ye100861 天前
第三章:内存泄漏的常见“案发现场”
c#·wpf
心平气和量大福大2 天前
C#-WPF-UserControl-生命周期(加载 退出)
开发语言·c#·wpf
czhc11400756632 天前
7.23:Claude code:注册->封表
wpf
心平气和量大福大2 天前
C#-WPF-控件-TextBox 数据绑定
开发语言·c#·wpf
listening7773 天前
HarmonyOS 6.1 全场景协同实战:从“单机”到“超级终端”的分布式重构
wpf
心平气和量大福大3 天前
C#-WPF-布局-Grid
c#·wpf·visual studio
心平气和量大福大4 天前
C#-WPF-Window主窗体
开发语言·c#·wpf
FuckPatience5 天前
Telerik UI for WPF 值不能为null。参数名:key
ui·wpf
lindexi5 天前
WPF 笔迹延迟优化从硬件到软件的全链路分析
wpf
weixin_727535626 天前
双Token认证体系深度拆解:Spring Security + JWT + Redis
redis·spring·wpf