none
datagridview中的行头总是有箭头,怎么去掉,以便我能加自己的内容 RRS feed

  • 问题

  • datagridview中的行头总是有箭头(datagridview自带的),怎么去掉,(三角箭头不显示),以便我能加自己的内容。
    dyx9010
    2011年3月14日 2:10

答案

全部回复

  • 你好!

    这应该是排序后的箭头,取消列的排序就行了。

    void InitDemo()
    {
      DataTable dt = new DataTable();
      dt.Columns.Add("Id");
      this.dataGridView1.DataSource = dt;
      this.dataGridView1.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dataGridView1_DataBindingComplete);
    }
    
    void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
    {
      foreach (DataGridViewColumn col in this.dataGridView1.Columns)
      {
        col.SortMode = DataGridViewColumnSortMode.NotSortable;
      }
    }
    


    知识改变命运,奋斗成就人生!
    2011年3月14日 3:36
    版主
  • 我说的是行头,不是列头有三角箭头


    dyx9010
    2011年3月14日 10:48
  • 你好

    这个是封装好的控件,貌似改不了。不过你可以设置dataGridView的RowHeadersVisible=false。这样的话隐藏掉第一列。

    然后自己设计一新列,去加入你想要的内容。

    希望对你有帮助。


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年3月15日 9:12