fixed some bugs
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Reader
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private static readonly HttpClient http = new HttpClient();
|
||||
private const string ServerUrl = "http://localhost:5000";
|
||||
private const string ServerUrl = "http://192.168.0.125:5000";
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
@@ -93,6 +93,34 @@ namespace Reader
|
||||
var sb = new StringBuilder();
|
||||
foreach (var b in hash) sb.Append(b.ToString("x2"));
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// 1. 去除自动尺寸模式的限制,改用手动指定
|
||||
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
|
||||
|
||||
// 2. 计算每一列的理想宽度
|
||||
// 假设您有 N 列,除了最后一列,其余列平分空间
|
||||
int columnCount = dgv.Columns.Count;
|
||||
int totalWidth = dgv.ClientSize.Width; // 获取控件当前宽度
|
||||
|
||||
// 3. 遍历每一列
|
||||
for (int i = 0; i < columnCount; i++)
|
||||
{
|
||||
// 这里做一个简单的平均分配逻辑
|
||||
double width = totalWidth / columnCount;
|
||||
|
||||
// 设置列宽,注意:不能小于最小宽度
|
||||
dgv.Columns[i].Width = (int)Math.Ceiling(width);
|
||||
}
|
||||
|
||||
// 如果最后一列想稍微宽一点,或者确保宽度总和等于控件宽度,可以做微调
|
||||
int remaining = totalWidth - dgv.Columns.Cast<DataGridViewColumn>()
|
||||
.Take(columnCount - 1)
|
||||
.Sum(col => col.Width);
|
||||
|
||||
dgv.Columns[columnCount - 1].Width = remaining;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user