-
大小: 21.35MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-07-04
- 语言: 其他
- 标签: DevExpress GridView 行号宽度
资源简介
资源的相关博文链接 https://blog.csdn.net/u012097590/article/details/90898424
DevExpress的版本用的是17.1,资源内部版本转换的方法
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BestFitGridViewIndicatorWidth
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
BindCustomDrawRowIndicator(gridView1);
}
DataTable CreateDt(int rowCount)
{
var dt = new DataTable();
for (int i = 0; i < 3; i++)
{
dt.Columns.Add(“col“ + i);
}
for (int i = 0; i < rowCount; i++)
{
var dr = dt.NewRow();
for (int j = 0; j < dt.Columns.Count; j++)
{
dr[j] = $“col{i}{j}“;
}
dt.Rows.Add(dr);
}
return dt;
}
private void Form1_Load(object sender EventArgs e)
{
var dt = CreateDt(99999);
gridControl1.DataSource = dt;
}
void BindCustomDrawRowIndicator(DevExpress.XtraGrid.Views.Grid.GridView view)
{
view.IndicatorWidth = CalcIndicatorDefaultWidth(view);
view.CustomDrawRowIndicator += (s e) =>
{
if (e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
};
view.TopRowChanged += (s e) =>
{
int width = CalcIndicatorBestWidth(view);
if ((view.IndicatorWidth - 4 < width || view.IndicatorWidth + 4 > width) && view.IndicatorWidth != width)
{
view.IndicatorWidth = width;
}
};
}
///
/// 计算行头宽度
///
///
///
int CalcIndicatorBestWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
{
Graphics graphics = new Control().CreateGraphics();
SizeF sizeF = new SizeF();
int count = view.TopRowIndex + ((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo)view.GetViewInfo()).RowsInfo.Count;
if (count == 0)
{
count = 30;
}
sizeF = graphics.MeasureString(count.ToString() view.Appearance.Row.Font);
return Convert.ToInt32(sizeF.Width) + 20;
}
///
/// 计算默认的宽度
///
///
///
int CalcIndicatorDefaultWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
{
var grid = view.GridControl;
Graphics graphics = new Control().CreateGraphics();
SizeF sizeF = new SizeF();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-06-05 11:01 BestFitGridViewIndicatorWidth\
目录 0 2019-06-05 09:30 BestFitGridViewIndicatorWidth\.vs\
目录 0 2019-06-05 09:30 BestFitGridViewIndicatorWidth\.vs\BestFitGridViewIndicatorWidth\
目录 0 2019-06-05 09:30 BestFitGridViewIndicatorWidth\.vs\BestFitGridViewIndicatorWidth\v14\
文件 17408 2019-06-05 10:57 BestFitGridViewIndicatorWidth\.vs\BestFitGridViewIndicatorWidth\v14\.suo
目录 0 2019-06-05 10:38 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\
文件 4729 2019-06-05 10:22 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth.csproj
文件 2981 2019-06-05 10:38 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Form1.Designer.cs
文件 3426 2019-06-05 10:38 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Form1.cs
文件 5817 2019-06-05 10:38 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Form1.resx
文件 510 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Program.cs
目录 0 2019-06-05 10:57 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\
文件 1384 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\AssemblyInfo.cs
文件 2871 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\Resources.Designer.cs
文件 5612 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\Resources.resx
文件 1116 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\Settings.Designer.cs
文件 249 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\Settings.settings
文件 252 2019-06-05 10:57 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\Properties\licenses.licx
目录 0 2019-06-05 09:30 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\
目录 0 2019-06-05 10:22 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\
文件 12800 2019-06-05 10:57 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\BestFitGridViewIndicatorWidth.exe
文件 24064 2019-06-05 10:57 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\BestFitGridViewIndicatorWidth.pdb
文件 22688 2019-06-05 11:01 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\BestFitGridViewIndicatorWidth.vshost.exe
文件 490 2017-03-19 05:00 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\BestFitGridViewIndicatorWidth.vshost.exe.manifest
文件 6234352 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Data.v17.1.dll
文件 1330793 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Data.v17.1.xm
文件 2056432 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Office.v17.1.Core.dll
文件 100312 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Office.v17.1.Core.xm
文件 1820400 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Pdf.v17.1.Core.dll
文件 348857 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Pdf.v17.1.Core.xm
文件 4197616 2018-04-28 13:37 BestFitGridViewIndicatorWidth\BestFitGridViewIndicatorWidth\bin\Debug\DevExpress.Printing.v17.1.Core.dll
............此处省略90个文件信息
相关资源
- devexpress第三方控件库demo使用
- DevExpress Localized Resources 16.1
- DevExpress CodeRush v12.1 破解版
- DevExpress 和 XtraReport 中文帮助打包.r
- DevExpress NET v8.1.3(完美安装+破解+汉化
- DevExpress12.2.6源码
- devexpress 8.1.3 内含破解文件
- DevExpress-13.1.4.13163 源程序
- DevExpress12.2
- DevExpress VCL_v19.1.2修正版内嵌汉化资源
- Devexpress15.2.9源码
- Devexpress12.1
- DevExpress ImagePicker(图标选择器)封装
- devexpress表格控件gridcontrol禁用特定行
- DevExpress VCL_19.1.2_full_source(Delphi 10.
- DevExpress17.2.4-Visual Studio2017 完美破解
- DevExpress 最新版本14.1.4 破解
- Devexpress版本升级转换测试
- DevExpress9.2.6注册机
- GridView样式代码
- dev 13.1.8 安装程序+破解
- DataGridView实现课程表
- listview嵌gridview,并实现grid元素部分显
- GridView导出到Excel
- Devexpress Patch 17.2 三种方法破解
- DataGirdView同一列下拉框每一行显示不
- Devexpress18.2.7Crack.zip
- Devexpress 16.2.5 + 官方汉化+破解
- DevExpress 13.2.8 破解工具
- DevExpress 13.1.4 13.1.5 破解
评论
共有 条评论