动态地将列宽分配给winforms datagrid? [英] Dynamically assign a column width to a winforms datagrid?

查看:163
本文介绍了动态地将列宽分配给winforms datagrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个创建了我的datagrid列,

I ve created columns of my datagrid using this,

   private void Receive_Load(object sender, System.EventArgs e)
    {
        DataGridView1.Columns.Add("Sender",typeof(string));
        DataGridView1.Columns.Add("Time",typeof(string));
        DataGridView1.Columns.Add("Message",typeof(string));
    }




  • 如何动态分配列宽一个winforms datagrid?

  • 推荐答案

    我想你正在搜索一些线条

    I think you are searching for something line

    DataGridView1.Columns["ColumnName"].Width = 75;
    

    我希望它可以帮助你。

    此外,您可以设置列的AutoSizeMode以自动获取不同的行为。例如,如果将其设置为ColumnHeader,则单元格宽度将被设置为最适合显示标题文本。您可以在此链接中获取更多信息。

    In addition, you can set the AutoSizeMode of the column to obtain different behaviours automatically. For example, if you set it to ColumnHeader, then the cell width will be set to the best fit for showing the header text. You can get more info in this Link.

    这篇关于动态地将列宽分配给winforms datagrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆