如果设制DataGridView中每列的宽度, 按比例显示, 我的是用代码取的DataTable对象绑定的数据源

解决方案 »

  1.   

    <asp:TemplateField HeaderText="申請總量">
                                    <ItemTemplate>
    放这里面设着看看。再不行就用css控制了。
      

  2.   

    style="width : ??"
    这样行吗
      

  3.   

    简单的:自己按比例算出来后设置
    this.dataGridView1.Columns[0].Width = 1000;
    下面是复杂的
    http://topic.csdn.net/u/20080729/16/493d7d23-193f-481a-af5a-16c8adb02769.html设置他们的样式,你如果要记忆这些样式将他们保存到一个配置文件就行了,下次读取出来 
    msdn有详细的关于样式设置的说明以下为简单示例 创建和初始化新的 DataGridViewCellStyle 对象以供多个行和列使用。 C# codeDataGridViewCellStyle highlightCellStyle = new DataGridViewCellStyle();
    highlightCellStyle.BackColor = Color.Red;DataGridViewCellStyle currencyCellStyle = new DataGridViewCellStyle();
    currencyCellStyle.Format = "C";
    currencyCellStyle.ForeColor = Color.Green设置特定行和列的 DefaultCellStyle 属性。 C# codethis.dataGridView1.Rows[3].DefaultCellStyle = highlightCellStyle;
    this.dataGridView1.Rows[8].DefaultCellStyle = highlightCellStyle;
    this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle =
        currencyCellStyle;
    this.dataGridView1.Columns["TotalPrice"].DefaultCellStyle =
        currencyCellStyle;
    msdn的示例 C# codeprivate void SetDefaultCellStyles()
    {
        this.dataGridView1.DefaultCellStyle.BackColor = Color.Beige;
        this.dataGridView1.DefaultCellStyle.Font = new Font("Tahoma", 12);    DataGridViewCellStyle highlightCellStyle = new DataGridViewCellStyle();
        highlightCellStyle.BackColor = Color.Red;    DataGridViewCellStyle currencyCellStyle = new DataGridViewCellStyle();
        currencyCellStyle.Format = "C";
        currencyCellStyle.ForeColor = Color.Green;    this.dataGridView1.Rows[3].DefaultCellStyle = highlightCellStyle;
        this.dataGridView1.Rows[8].DefaultCellStyle = highlightCellStyle;
        this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle =
            currencyCellStyle;
        this.dataGridView1.Columns["TotalPrice"].DefaultCellStyle =
            currencyCellStyle;
    }