Add button column in a databound datagridview

后端 未结 4 1932
误落风尘
误落风尘 2020-12-10 16:35

i have a datagridview. i bound it to a list. now i want to show a column at the end of it. but that column apprear in wrong possition.

this is my code



        
相关标签:
4条回答
  • 2020-12-10 17:15

    Add column instead of inserting it to the GridView. It will automaticallyy append it to the end of column collection.

        grdPatientAppointment.Columns.Add(btnColumn);
    
    0 讨论(0)
  • 2020-12-10 17:16

    just add code below

    grdPatientAppointment.Columns.Insert(I, btnColumn)
    

    I is index of column you want to add

    0 讨论(0)
  • 2020-12-10 17:17

    Use grdPatientAppointment.AutoGenerateColumns = false;

    Then add all columns your grid will receive from DataSource and bind them from editor.

    0 讨论(0)
  • 2020-12-10 17:35

    Use DisplayIndex property to change the order of the columns: http://msdn.microsoft.com/en-us/library/wkfe535h.aspx

    0 讨论(0)
提交回复
热议问题