Home All Groups Group Topic Archive Search About

DataGridView column sort

Author
3 Jul 2006 1:32 PM
martin1
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

Author
3 Jul 2006 8:40 PM
Cor Ligthert [MVP]
Martin

Have a look at this

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

I hope this helps,

Cor


Show quoteHide quote
"martin1" <mart***@discussions.microsoft.com> schreef in bericht
news:999741C4-557B-43BB-9B76-F8E4CC700C79@microsoft.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
Author
6 Jul 2006 1:51 PM
martin1
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.SortedColumn.SortMode = DataGridViewColumnSortMode.NotSortable



Show quoteHide quote
"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" <mart***@discussions.microsoft.com> schreef in bericht
> news:999741C4-557B-43BB-9B76-F8E4CC700C79@microsoft.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
>
>
>
Author
6 Jul 2006 8:24 PM
martin1
use column_name like below works

DataGridView.Columns("column_name").SortMode =
DataGridViewColumnSortMode.NotSortable

Show quoteHide quote
"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.SortedColumn.SortMode = DataGridViewColumnSortMode.NotSortable
>
>
>
> "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" <mart***@discussions.microsoft.com> schreef in bericht
> > news:999741C4-557B-43BB-9B76-F8E4CC700C79@microsoft.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
> >
> >
> >