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;

}

}

相关推荐
明耀8 小时前
WPF DataGrid 默认显示行号
wpf
lph197212 小时前
wpf的converter
wpf
fyifei055812 小时前
WPF学习PropertyChanged
wpf
爱炸薯条的小朋友13 小时前
C#由于获取WPF窗口名称造成的异常报错问题
windows·c#·wpf
baivfhpwxf202313 小时前
wpf ListBox 去除item 单击样式
wpf
诗仙&李白13 小时前
lnnovationHubTool,用prism+WPF编写的MVVM模式的快速上位机软件开发框架平台
wpf·mvvm·prism·上位机软件开发框架平台
程序员小刘17 小时前
【HarmonyOS 5】教育开发实践详解以及详细代码案例
华为·wpf·harmonyos
Java Fans1 天前
在WPF项目中集成Python:Python.NET深度实战指南
python·.net·wpf
布伦鸽2 天前
C# WPF 左右布局实现学习笔记(1)
笔记·学习·c#·wpf
code bean3 天前
【WPF】WPF 项目实战:构建一个可增删、排序的光源类型管理界面(含源码)
wpf