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;

}

}

相关推荐
没有bug.的程序员20 小时前
服务治理与 API 网关:微服务流量管理的艺术
java·分布式·微服务·架构·wpf
Brianna Home1 天前
【案例实战】鸿蒙分布式调度:跨设备协同实战
华为·wpf·harmonyos
c#上位机2 天前
wpf中Grid的MouseDown 事件无法触发的原因
c#·wpf
△曉風殘月〆2 天前
如何在WPF中实现ComboBox多选
wpf
csdn_aspnet2 天前
如何使用现有工具进行 .NET 8 迁移 Wpf
wpf·.net 8
123梦野3 天前
WPF——动画
wpf
攻城狮CSU3 天前
WPF 疑点汇总2.HorizontalAlignment和 HorizontalContentAlignment
wpf
c#上位机3 天前
wpf之命令
c#·wpf
没有bug.的程序员3 天前
分布式链路追踪:微服务可观测性的核心支柱
java·分布式·微服务·架构·wpf
Aevget4 天前
DevExpress WPF中文教程:Data Grid - 如何使用虚拟源?(一)
c#·wpf·界面控件·devexpress·ui开发