* UIDataGridView: 更新DPI缩放对控件的适配
This commit is contained in:
parent
6bf1643a3b
commit
fd70439508
Binary file not shown.
Binary file not shown.
2
SunnyUI.Demo/Controls/FDataGridView.Designer.cs
generated
2
SunnyUI.Demo/Controls/FDataGridView.Designer.cs
generated
@ -43,6 +43,7 @@ namespace Sunny.UI.Demo
|
|||||||
//
|
//
|
||||||
// uiDataGridViewFooter1
|
// uiDataGridViewFooter1
|
||||||
//
|
//
|
||||||
|
this.uiDataGridViewFooter1.DataGridView = null;
|
||||||
this.uiDataGridViewFooter1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.uiDataGridViewFooter1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.uiDataGridViewFooter1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.uiDataGridViewFooter1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.uiDataGridViewFooter1.Location = new System.Drawing.Point(0, 386);
|
this.uiDataGridViewFooter1.Location = new System.Drawing.Point(0, 386);
|
||||||
@ -114,6 +115,7 @@ namespace Sunny.UI.Demo
|
|||||||
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
|
this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
|
||||||
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
|
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
|
||||||
|
dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||||
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
|
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
|
||||||
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||||
|
@ -10,11 +10,14 @@ namespace Sunny.UI.Demo
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
//SunnyUI封装的加列函数,也可以和原生的一样,从Columns里面添加列
|
||||||
uiDataGridView1.AddColumn("Column1", "Column1");
|
uiDataGridView1.AddColumn("Column1", "Column1");
|
||||||
uiDataGridView1.AddColumn("Column2", "Column2");
|
uiDataGridView1.AddColumn("Column2", "Column2");
|
||||||
uiDataGridView1.AddColumn("Column3", "Column3");
|
uiDataGridView1.AddColumn("Column3", "Column3");
|
||||||
uiDataGridView1.AddColumn("Column4", "Column4");
|
uiDataGridView1.AddColumn("Column4", "Column4");
|
||||||
uiDataGridView1.ReadOnly = true;
|
|
||||||
|
//SunnyUI常用的初始化配置,看个人喜好用或者不用。
|
||||||
|
uiDataGridView1.Init();
|
||||||
|
|
||||||
for (int i = 0; i < 3610; i++)
|
for (int i = 0; i < 3610; i++)
|
||||||
{
|
{
|
||||||
|
@ -74,12 +74,17 @@ namespace Sunny.UI
|
|||||||
ColumnHeadersDefaultCellStyle.BackColor = UIColor.Blue;
|
ColumnHeadersDefaultCellStyle.BackColor = UIColor.Blue;
|
||||||
ColumnHeadersDefaultCellStyle.ForeColor = UIColor.White;
|
ColumnHeadersDefaultCellStyle.ForeColor = UIColor.White;
|
||||||
ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
|
ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
|
||||||
|
ColumnHeadersDefaultCellStyle.Font = UIFontColor.Font();
|
||||||
|
|
||||||
//行头部颜色
|
//行头部颜色
|
||||||
RowHeadersDefaultCellStyle.BackColor = UIColor.LightBlue;
|
RowHeadersDefaultCellStyle.BackColor = UIColor.LightBlue;
|
||||||
RowHeadersDefaultCellStyle.ForeColor = UIFontColor.Primary;
|
RowHeadersDefaultCellStyle.ForeColor = UIFontColor.Primary;
|
||||||
RowHeadersDefaultCellStyle.SelectionBackColor = UIColor.Blue;
|
RowHeadersDefaultCellStyle.SelectionBackColor = UIColor.Blue;
|
||||||
RowHeadersDefaultCellStyle.SelectionForeColor = Color.White;
|
RowHeadersDefaultCellStyle.SelectionForeColor = Color.White;
|
||||||
|
RowHeadersDefaultCellStyle.Font = UIFontColor.Font();
|
||||||
|
|
||||||
|
RowsDefaultCellStyle.Font = UIFontColor.Font();
|
||||||
|
DefaultCellStyle.Font = UIFontColor.Font();
|
||||||
|
|
||||||
//标题行行高,与OnColumnAdded事件配合
|
//标题行行高,与OnColumnAdded事件配合
|
||||||
ColumnHeadersHeight = 32;
|
ColumnHeadersHeight = 32;
|
||||||
@ -106,7 +111,6 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (!IsScaled)
|
if (!IsScaled)
|
||||||
{
|
{
|
||||||
this.SetDPIScaleFont();
|
|
||||||
if (ColumnHeadersDefaultCellStyle.Font != null)
|
if (ColumnHeadersDefaultCellStyle.Font != null)
|
||||||
ColumnHeadersDefaultCellStyle.Font = ColumnHeadersDefaultCellStyle.Font.DPIScaleFont();
|
ColumnHeadersDefaultCellStyle.Font = ColumnHeadersDefaultCellStyle.Font.DPIScaleFont();
|
||||||
if (RowHeadersDefaultCellStyle.Font != null)
|
if (RowHeadersDefaultCellStyle.Font != null)
|
||||||
|
@ -86,7 +86,14 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
foreach (Control control in this.GetAllDPIScaleControls())
|
foreach (Control control in this.GetAllDPIScaleControls())
|
||||||
{
|
{
|
||||||
control.SetDPIScaleFont();
|
if (control is UIDataGridView dgv)
|
||||||
|
{
|
||||||
|
dgv.SetDPIScale();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control.SetDPIScaleFont();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsScaled = true;
|
IsScaled = true;
|
||||||
|
@ -85,7 +85,14 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
foreach (Control control in this.GetAllDPIScaleControls())
|
foreach (Control control in this.GetAllDPIScaleControls())
|
||||||
{
|
{
|
||||||
control.SetDPIScaleFont();
|
if (control is UIDataGridView dgv)
|
||||||
|
{
|
||||||
|
dgv.SetDPIScale();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
control.SetDPIScaleFont();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsScaled = true;
|
IsScaled = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user