70分:  http://community.csdn.net/Expert/topic/4092/4092426.xml?temp=.2082941
26分:  http://community.csdn.net/Expert/topic/4091/4091493.xml?temp=.1310388LaoDai_Net(『老代.Net』) 您的代码我试了, 没效果, 单元格是等长的.

解决方案 »

  1.   

    http://www.syncfusion.com/FAQ/WindowsForms/Default.aspx#44
      

  2.   

    http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q877q
      

  3.   

    是这段代码对吗?  在使用时要传入调整列的索引号
    请问最后一句 dataGrid1.TableStyles["customers"]  中的 customers 是表名吗
    是怎么设置的.
    dataGrid1要绑定的是dastset 还是dataview
    public void AutoSizeCol(int col) // 参数是索引号对吗

         float width = 0; 
         int numRows = ((DataTable) dataGrid1.DataSource).Rows.Count;          
     
         Graphics g = Graphics.FromHwnd(dataGrid1.Handle); 
         StringFormat sf = new StringFormat(StringFormat.GenericTypographic); 
         SizeF size;      for(int i = 0; i < numRows; ++ i) 
         { 
             size = g.MeasureString(dataGrid1[i, col].ToString(), dataGrid1.Font, 500, sf); 
              if(size.Width > width) 
                   width = size.Width; 
         }      g.Dispose();      dataGrid1.TableStyles["customers"].GridColumnStyles[col].Width = (int) width + 8; // 8 is for leading and trailing padding 
    }
      

  4.   

    就是 kokopp(你好我也好)的方法
      

  5.   

    是CMIC(大象)发给我的, 看上去能实现我所要的功能
    我循环调用数据表的列, 每列都调用一次自动调整, 可就是没效果.我怀疑是 dataGrid1.TableStyles["customers"]. 有问题, 或是 dataGrid1 数据绑定有问题(数据集还是数据视图)  所以在发帖子问问, 有人能回答我吗