// 根据列的多少,智能设置列宽度 void SetColumnWidth() { if (this.listView1.View == View.Details) { int nMaxColumns = 0; for (int i = 0; i < this.listView1.Items.Count; i++) { ListViewItem item = this.listView1.Items[i]; if (item.SubItems.Count > nMaxColumns) { nMaxColumns = item.SubItems.Count; } } if (nMaxColumns == 1) { this.columnHeader_name.Width = this.listView1.Width - SystemInformation.Border3DSize.Height * 4 - SystemInformation.VerticalScrollBarWidth; this.columnHeader_comment.Width = 0; } else if (_withSetted == false) { // 从 96 DPI 下的数量翻译为物理像素数 int value = DpiUtil.GetScalingX(DpiUtil.GetDpiXY(this), this.columnHeader_name.Width); this.columnHeader_name.Width = value; value = DpiUtil.GetScalingX(DpiUtil.GetDpiXY(this), this.columnHeader_comment.Width); this.columnHeader_comment.Width = value; _withSetted = true; } } }
private void panel1_Paint(object sender, PaintEventArgs e) { Point pt = this.panel1.AutoScrollPosition; e.Graphics.TranslateTransform(pt.X, pt.Y); MergePicture.SetMetrics(DpiUtil.GetDpiXY(this)); Size size = MergePicture.Paint(e, this.panel1.ClientSize, this.Font, "源 " + this.SourceRecPath, "目标 " + this.TargetRecPath, GetMergeStyle()); this.panel1.AutoScrollMinSize = size; // this.panel1.SetBounds(0, 0, size.Width, size.Height, BoundsSpecified.All); }