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

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

private void FlexGrid_LoadedRows_RowIndex(object sender, EventArgs e)

{

ViewHelper.SetRowIndexNoPage(CfgReviewItem);

//CfgReviewItem.Rows[0].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.Rows[0].Height = 200;

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

}

public void setHeight(int height,int i) {

if (height < 100)

{

CfgReviewItem.Rows[i].Height = 50;

}

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

{

CfgReviewItem.Rows[i].Height = 100;

}

else if (height > 200)

{

CfgReviewItem.Rows[i].Height = 200;

}

}

相关推荐
西岭千秋雪_44 分钟前
Zookeeper实现分布式锁
java·分布式·后端·zookeeper·wpf
beyond谚语8 小时前
第三章 布局
wpf
Aevget21 小时前
界面控件DevExpress WPF v25.1新版亮点:数据管理功能全新升级
.net·wpf·界面控件·devexpress·ui开发
baivfhpwxf202321 小时前
要在 WPF 中实现数据表对应实体的属性与 UI 控件的双向绑定,并支持修改通知和 UI 自动更新
c#·wpf
极客智造1 天前
深入解析 WPF 中的 DataTemplateSelector:动态模板选择的艺术
wpf
极客智造1 天前
WPF 高级 UI 定制:深入解析 VisualStateManager 与 Adorner
wpf
LateFrames3 天前
使用 Winform / WPF / WinUI3 / Electron 实现异型透明窗口
javascript·electron·wpf·winform·winui3
ifeng09183 天前
HarmonyOS实战项目:AI健康助手(影像识别与健康分析)
人工智能·华为·wpf·harmonyos
Aevget3 天前
界面控件Telerik UI for WPF 2025 Q3亮点 - 集成AI编码助手
人工智能·ui·wpf·界面控件·ui开发·telerik
张人玉3 天前
WPF 数据绑定与转换器详解
c#·wpf·light