如何更改 DataGrid 的列宽

发布于 2024-09-19 15:28:41 字数 177 浏览 2 评论 0原文

我正在 C# .net 紧凑框架 3.5 中创建用户控件。 我使用带有 DataTable 的 DataGrid 控件作为 DataGrid 的数据源。 我需要使一些网格列更宽。

由于某种原因我不能...

我只是找不到控制列宽的方法或属性...

有什么想法吗?

提前致谢...

i'm creating a user control in C# .net compact framework 3.5.
And i'm using a DataGrid Control with a DataTable as the DataGrid's DataSource.
i need to make some of the grid columns wider.

for some reason i can't...

i just couldn't find the method or property that controls the column width...

any ideas?

thanks in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铁憨憨 2024-09-26 15:28:41

您正在寻找列的 AutoSizeModeWidth 属性。

You're looking for the AutoSizeMode and Width properties of the columns.

猫弦 2024-09-26 15:28:41

下面的示例代码 -

foreach(DataGridColumnStyle vColumnStyle in myGrid.TableStyles[0].GridColumnStyles )
{
    if (vColumnStyle.HeaderText.ToLower()=="mycolumn")    
    {                
        vColumnStyle.Width = 60;            
    }
}

sample code below -

foreach(DataGridColumnStyle vColumnStyle in myGrid.TableStyles[0].GridColumnStyles )
{
    if (vColumnStyle.HeaderText.ToLower()=="mycolumn")    
    {                
        vColumnStyle.Width = 60;            
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文