DataGridView column sort

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • martin1

    #1

    DataGridView column sort

    All,

    ..Net 2.0 DataGridView column sort is automatic, I don't want column sort, is
    anybody know how to not sort column in DataGridView?

    Thanks
  • Cor Ligthert [MVP]

    #2
    Re: DataGridView column sort

    Martin

    Have a look at this

    http://msdn2.microsoft.com/en-us/library/95scxcdy.aspx

    I hope this helps,

    Cor


    "martin1" <martin1@discus sions.microsoft .comschreef in bericht
    news:999741C4-557B-43BB-9B76-F8E4CC700C79@mi crosoft.com...
    All,
    >
    .Net 2.0 DataGridView column sort is automatic, I don't want column sort,
    is
    anybody know how to not sort column in DataGridView?
    >
    Thanks

    Comment

    • martin1

      #3
      Re: DataGridView column sort

      Hi, Cor,

      when using following code to disable column sort and get "Object reference
      not set to an instance of an object" error message, it is NullReference
      Exception, the dataGridView1 is already created by draging the datagrid onto
      the form, can you help this out? Thanks

      DataGridView1.S ortedColumn.Sor tMode = DataGridViewCol umnSortMode.Not Sortable



      "Cor Ligthert [MVP]" wrote:
      Martin
      >
      Have a look at this
      >
      http://msdn2.microsoft.com/en-us/library/95scxcdy.aspx
      >
      I hope this helps,
      >
      Cor
      >
      >
      "martin1" <martin1@discus sions.microsoft .comschreef in bericht
      news:999741C4-557B-43BB-9B76-F8E4CC700C79@mi crosoft.com...
      All,

      .Net 2.0 DataGridView column sort is automatic, I don't want column sort,
      is
      anybody know how to not sort column in DataGridView?

      Thanks
      >
      >
      >

      Comment

      • martin1

        #4
        Re: DataGridView column sort

        use column_name like below works

        DataGridView.Co lumns("column_n ame").SortMode =
        DataGridViewCol umnSortMode.Not Sortable

        "martin1" wrote:
        Hi, Cor,
        >
        when using following code to disable column sort and get "Object reference
        not set to an instance of an object" error message, it is NullReference
        Exception, the dataGridView1 is already created by draging the datagrid onto
        the form, can you help this out? Thanks
        >
        DataGridView1.S ortedColumn.Sor tMode = DataGridViewCol umnSortMode.Not Sortable
        >
        >
        >
        "Cor Ligthert [MVP]" wrote:
        >
        Martin

        Have a look at this

        http://msdn2.microsoft.com/en-us/library/95scxcdy.aspx

        I hope this helps,

        Cor


        "martin1" <martin1@discus sions.microsoft .comschreef in bericht
        news:999741C4-557B-43BB-9B76-F8E4CC700C79@mi crosoft.com...
        All,
        >
        .Net 2.0 DataGridView column sort is automatic, I don't want column sort,
        is
        anybody know how to not sort column in DataGridView?
        >
        Thanks

        Comment

        Working...