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;

}

}

相关推荐
gis开发之家1 天前
Spring Boot 4 定时任务与异步线程池:从 @Scheduled 到高并发任务编排(生产级实战)
java·spring boot·后端·wpf·spring boot4
clz13145212 天前
如何设计一个优雅可靠的金融级联机接口
wpf
闲云自留地3 天前
云平台存储管理员:Cinder 创建挂载卷 + Swift 分布式存储原理
分布式·wpf·swift
敲代码的嘎仔4 天前
从集群锁失效到异步领券:我用分布式锁 + Redisson + MQ 把领券接口 RT 从 200ms 压到 15ms
java·数据库·redis·分布式·缓存·ai·wpf
闲云自留地4 天前
OpenStack 的身份管家:Keystone 令牌、RBAC 权限模型拆解
wpf·openstack
FuckPatience6 天前
WPF 窗体唤醒,判断是否已存在,存在则弹出
wpf
程序员清风6 天前
从单体应用到微服务:后端系统拆分的基本方法
微服务·架构·wpf
FuckPatience7 天前
WPF 改变根据某一列条件改变行样式
wpf
dalong108 天前
WPF:DataGrid样式
wpf
samble9 天前
从零搭建工业控制系统(二十二):线程安全与并发控制
c#·wpf·并发·mvvm·线程安全·工业控制