Hi,
is it possible to sort DataGridViewComboBoxColumn type columns by
clicking on the header cell (in DataGridViewColumnSortMode.Automatic
case)? It doesn't seem to work or there is a bug in my code. There
should be an arrow sign (triangle) in the header cell after clicking on
it, but there doesn't appear any...

Thanks for any help.

With regards
nvx

Re: Sorting of DataGridViewComboBoxColumn type columns by Kevin

Kevin
Mon Jul 17 14:39:10 CDT 2006

Yes, it's possible, but I don't know why you're having a problem.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.


"nvx" <nvx2004@hotmail.com> wrote in message
news:1153162388.647427.30240@35g2000cwc.googlegroups.com...
> Hi,
> is it possible to sort DataGridViewComboBoxColumn type columns by
> clicking on the header cell (in DataGridViewColumnSortMode.Automatic
> case)? It doesn't seem to work or there is a bug in my code. There
> should be an arrow sign (triangle) in the header cell after clicking on
> it, but there doesn't appear any...
>
> Thanks for any help.
>
> With regards
> nvx
>



Re: Sorting of DataGridViewComboBoxColumn type columns by nvx

nvx
Tue Jul 18 00:42:18 CDT 2006

Thank you for the information. I'll try to go through the code and find
the problem.

One more thing: is there any other property of
DataGridViewComboBoxColumn columns that HAS to be set to some value for
this to work (except the DataGridViewColumnSortMode.Automatic; I'm
generating the DataGridViewComboBoxColumn columns on the fly...)?

Many thanks...

With regards
nvx


Kevin Spencer wrote:
> Yes, it's possible, but I don't know why you're having a problem.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> What You Seek Is What You Get.
>
>
> "nvx" <nvx2004@hotmail.com> wrote in message
> news:1153162388.647427.30240@35g2000cwc.googlegroups.com...
> > Hi,
> > is it possible to sort DataGridViewComboBoxColumn type columns by
> > clicking on the header cell (in DataGridViewColumnSortMode.Automatic
> > case)? It doesn't seem to work or there is a bug in my code. There
> > should be an arrow sign (triangle) in the header cell after clicking on
> > it, but there doesn't appear any...
> >
> > Thanks for any help.
> >
> > With regards
> > nvx
> >


Re: Sorting of DataGridViewComboBoxColumn type columns by Kevin

Kevin
Tue Jul 18 05:30:25 CDT 2006

Are you using a DataSource for the columns? Are you setting the SortMode? I
have found the following White Paper helpful:

http://download.microsoft.com/download/5/6/4/5646742C-3EB7-48F7-BFB3-CC295D618CF9/DataGridView%20FAQ.doc

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.



"nvx" <nvx2004@hotmail.com> wrote in message
news:1153201338.921853.284880@35g2000cwc.googlegroups.com...
> Thank you for the information. I'll try to go through the code and find
> the problem.
>
> One more thing: is there any other property of
> DataGridViewComboBoxColumn columns that HAS to be set to some value for
> this to work (except the DataGridViewColumnSortMode.Automatic; I'm
> generating the DataGridViewComboBoxColumn columns on the fly...)?
>
> Many thanks...
>
> With regards
> nvx
>
>
> Kevin Spencer wrote:
>> Yes, it's possible, but I don't know why you're having a problem.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Chicken Salad Alchemist
>>
>> What You Seek Is What You Get.
>>
>>
>> "nvx" <nvx2004@hotmail.com> wrote in message
>> news:1153162388.647427.30240@35g2000cwc.googlegroups.com...
>> > Hi,
>> > is it possible to sort DataGridViewComboBoxColumn type columns by
>> > clicking on the header cell (in DataGridViewColumnSortMode.Automatic
>> > case)? It doesn't seem to work or there is a bug in my code. There
>> > should be an arrow sign (triangle) in the header cell after clicking on
>> > it, but there doesn't appear any...
>> >
>> > Thanks for any help.
>> >
>> > With regards
>> > nvx
>> >
>



Re: Sorting of DataGridViewComboBoxColumn type columns by nvx

nvx
Tue Jul 18 06:25:53 CDT 2006

Thank you very much, I'll read the document. It looks very useful.

Yes, DataSource for the ComboBox items is an ArrayList of Strings.
SortMode is set to Automatic when I programatically add the
DataGridViewComboBoxColumn column into the DataGridView.

With regards
nvx


Kevin Spencer wrote:
> Are you using a DataSource for the columns? Are you setting the SortMode? I
> have found the following White Paper helpful:
>
> http://download.microsoft.com/download/5/6/4/5646742C-3EB7-48F7-BFB3-CC295D618CF9/DataGridView%20FAQ.doc
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> What You Seek Is What You Get.
>
>
>
> "nvx" <nvx2004@hotmail.com> wrote in message
> news:1153201338.921853.284880@35g2000cwc.googlegroups.com...
> > Thank you for the information. I'll try to go through the code and find
> > the problem.
> >
> > One more thing: is there any other property of
> > DataGridViewComboBoxColumn columns that HAS to be set to some value for
> > this to work (except the DataGridViewColumnSortMode.Automatic; I'm
> > generating the DataGridViewComboBoxColumn columns on the fly...)?
> >
> > Many thanks...
> >
> > With regards
> > nvx
> >
> >
> > Kevin Spencer wrote:
> >> Yes, it's possible, but I don't know why you're having a problem.
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> Professional Chicken Salad Alchemist
> >>
> >> What You Seek Is What You Get.
> >>
> >>
> >> "nvx" <nvx2004@hotmail.com> wrote in message
> >> news:1153162388.647427.30240@35g2000cwc.googlegroups.com...
> >> > Hi,
> >> > is it possible to sort DataGridViewComboBoxColumn type columns by
> >> > clicking on the header cell (in DataGridViewColumnSortMode.Automatic
> >> > case)? It doesn't seem to work or there is a bug in my code. There
> >> > should be an arrow sign (triangle) in the header cell after clicking on
> >> > it, but there doesn't appear any...
> >> >
> >> > Thanks for any help.
> >> >
> >> > With regards
> >> > nvx
> >> >
> >


Re: Sorting of DataGridViewComboBoxColumn type columns by Kevin

Kevin
Tue Jul 18 10:16:50 CDT 2006

I meant, are you using a DataSource for the DataGridView columns?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.


"nvx" <nvx2004@hotmail.com> wrote in message
news:1153221953.121776.13630@p79g2000cwp.googlegroups.com...
> Thank you very much, I'll read the document. It looks very useful.
>
> Yes, DataSource for the ComboBox items is an ArrayList of Strings.
> SortMode is set to Automatic when I programatically add the
> DataGridViewComboBoxColumn column into the DataGridView.
>
> With regards
> nvx
>
>
> Kevin Spencer wrote:
>> Are you using a DataSource for the columns? Are you setting the SortMode?
>> I
>> have found the following White Paper helpful:
>>
>> http://download.microsoft.com/download/5/6/4/5646742C-3EB7-48F7-BFB3-CC295D618CF9/DataGridView%20FAQ.doc
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Chicken Salad Alchemist
>>
>> What You Seek Is What You Get.
>>
>>
>>
>> "nvx" <nvx2004@hotmail.com> wrote in message
>> news:1153201338.921853.284880@35g2000cwc.googlegroups.com...
>> > Thank you for the information. I'll try to go through the code and find
>> > the problem.
>> >
>> > One more thing: is there any other property of
>> > DataGridViewComboBoxColumn columns that HAS to be set to some value for
>> > this to work (except the DataGridViewColumnSortMode.Automatic; I'm
>> > generating the DataGridViewComboBoxColumn columns on the fly...)?
>> >
>> > Many thanks...
>> >
>> > With regards
>> > nvx
>> >
>> >
>> > Kevin Spencer wrote:
>> >> Yes, it's possible, but I don't know why you're having a problem.
>> >>
>> >> --
>> >> HTH,
>> >>
>> >> Kevin Spencer
>> >> Microsoft MVP
>> >> Professional Chicken Salad Alchemist
>> >>
>> >> What You Seek Is What You Get.
>> >>
>> >>
>> >> "nvx" <nvx2004@hotmail.com> wrote in message
>> >> news:1153162388.647427.30240@35g2000cwc.googlegroups.com...
>> >> > Hi,
>> >> > is it possible to sort DataGridViewComboBoxColumn type columns by
>> >> > clicking on the header cell (in DataGridViewColumnSortMode.Automatic
>> >> > case)? It doesn't seem to work or there is a bug in my code. There
>> >> > should be an arrow sign (triangle) in the header cell after clicking
>> >> > on
>> >> > it, but there doesn't appear any...
>> >> >
>> >> > Thanks for any help.
>> >> >
>> >> > With regards
>> >> > nvx
>> >> >
>> >
>



Re: Sorting of DataGridViewComboBoxColumn type columns by nvx

nvx
Tue Jul 18 11:14:54 CDT 2006

I'm sorry, I must have misunderstood.

Yes, the DataGridView is bound to an Access database table. After the
grid is filled with data, user can add or remove
DataGridViewComboBoxColumn columns.

Kevin Spencer napsal(a):
> I meant, are you using a DataSource for the DataGridView columns?
>

Re: Sorting of DataGridViewComboBoxColumn type columns by nvx

nvx
Tue Jul 18 13:18:34 CDT 2006

Well, it seems I didn't have set the DataPropertyName correctly. Due to
certain things one letter was in lowercase and everything went wrong.

Uff, I'm glad it's working... :)

Kevin, thank you very much for your help.

With regards
nvx


nvx napsal(a):
> I'm sorry, I must have misunderstood.
>
> Yes, the DataGridView is bound to an Access database table. After the
> grid is filled with data, user can add or remove
> DataGridViewComboBoxColumn columns.
>
> Kevin Spencer napsal(a):
>> I meant, are you using a DataSource for the DataGridView columns?
>>

Re: Sorting of DataGridViewComboBoxColumn type columns by whittetinternet

whittetinternet
Wed Jul 26 16:46:58 CDT 2006

I also have a problem doing this. It doesn't seem to work out of the
box and I'm not sure which method is the best to choose to solve it. I
have the DataGridView FAQ and it is great, but in this case it appears
that having a DataSource assigned is hurting my options of sorting on a
field not assigned to the DataSource's DataTable.

I have a DataGridView bound to a DataTable. I then add a
DataGridViewComboBoxColumn and this all works. Now when I click this
column the sort apprears to sort on the ID instead of the NAME
displayed in the combo box.
I have
cbo.DataPropertyName = "SalesUnitID"
cbo.DisplayMember = "NAME"; //Name from the SalesUnit table.
cbo.ValueMember = "ID"; //ID from the SalesUnit table.

--The e-mail is trash, post your response please:)

nvx wrote:
> Well, it seems I didn't have set the DataPropertyName correctly. Due to
> certain things one letter was in lowercase and everything went wrong.
>
> Uff, I'm glad it's working... :)
>
> Kevin, thank you very much for your help.
>
> With regards
> nvx
>
>
> nvx napsal(a):
> > I'm sorry, I must have misunderstood.
> >
> > Yes, the DataGridView is bound to an Access database table. After the
> > grid is filled with data, user can add or remove
> > DataGridViewComboBoxColumn columns.
> >
> > Kevin Spencer napsal(a):
> >> I meant, are you using a DataSource for the DataGridView columns?
> >>


Re: Sorting of DataGridViewComboBoxColumn type columns by whittetinternet

whittetinternet
Wed Jul 26 16:48:12 CDT 2006

I also have a problem doing this. It doesn't seem to work out of the
box and I'm not sure which method is the best to choose to solve it. I
have the DataGridView FAQ and it is great, but in this case it appears
that having a DataSource assigned is hurting my options of sorting on a
field not assigned to the DataSource's DataTable.

I have a DataGridView bound to a DataTable. I then add a
DataGridViewComboBoxColumn and this all works. Now when I click this
column the sort apprears to sort on the ID instead of the NAME
displayed in the combo box.
I have
cbo.DataPropertyName = "SalesUnitID"
cbo.DisplayMember = "NAME"; //Name from the SalesUnit table.
cbo.ValueMember = "ID"; //ID from the SalesUnit table.

--The e-mail is trash, post your response please:)

nvx wrote:
> Well, it seems I didn't have set the DataPropertyName correctly. Due to
> certain things one letter was in lowercase and everything went wrong.
>
> Uff, I'm glad it's working... :)
>
> Kevin, thank you very much for your help.
>
> With regards
> nvx
>
>
> nvx napsal(a):
> > I'm sorry, I must have misunderstood.
> >
> > Yes, the DataGridView is bound to an Access database table. After the
> > grid is filled with data, user can add or remove
> > DataGridViewComboBoxColumn columns.
> >
> > Kevin Spencer napsal(a):
> >> I meant, are you using a DataSource for the DataGridView columns?
> >>


Re: Sorting of DataGridViewComboBoxColumn type columns by whittetinternet

whittetinternet
Wed Jul 26 16:54:56 CDT 2006

Here is what I have now:
dataView.Sort = dataGridView.SortedColumn.Name + " " +
(direction == ListSortDirection.Ascending ?
"ASC " : "DESC ");

Do I need to databind to a dataView with the sort?

Right now I am using a single DataTable for the binding to the grid and
a second dataTable for the Sales Unit combobox's DataSource.

So the following only sorts on the ID. Would the solution be to put
both DataTables in a DataSet and then sort on the view with the column
being sorted being "Parent(SalesUnit).Name"?

whittetinter...@earthlink.net wrote:
> I also have a problem doing this. It doesn't seem to work out of the
> box and I'm not sure which method is the best to choose to solve it. I
> have the DataGridView FAQ and it is great, but in this case it appears
> that having a DataSource assigned is hurting my options of sorting on a
> field not assigned to the DataSource's DataTable.
>
> I have a DataGridView bound to a DataTable. I then add a
> DataGridViewComboBoxColumn and this all works. Now when I click this
> column the sort apprears to sort on the ID instead of the NAME
> displayed in the combo box.
> I have
> cbo.DataPropertyName = "SalesUnitID"
> cbo.DisplayMember = "NAME"; //Name from the SalesUnit table.
> cbo.ValueMember = "ID"; //ID from the SalesUnit table.
>
> --The e-mail is trash, post your response please:)
>
> nvx wrote:
> > Well, it seems I didn't have set the DataPropertyName correctly. Due to
> > certain things one letter was in lowercase and everything went wrong.
> >
> > Uff, I'm glad it's working... :)
> >
> > Kevin, thank you very much for your help.
> >
> > With regards
> > nvx
> >
> >
> > nvx napsal(a):
> > > I'm sorry, I must have misunderstood.
> > >
> > > Yes, the DataGridView is bound to an Access database table. After the
> > > grid is filled with data, user can add or remove
> > > DataGridViewComboBoxColumn columns.
> > >
> > > Kevin Spencer napsal(a):
> > >> I meant, are you using a DataSource for the DataGridView columns?
> > >>


Re: Sorting of DataGridViewComboBoxColumn type columns by Kevin

Kevin
Wed Jul 26 21:44:27 CDT 2006

You'll have to forgive me. It's late, and I've put in a long day (in a long
series of long days!). In addition, I haven't worked on this particular
project for awhile, and the DataGridView is one complex critter, so I may be
a bit lax in my recollection. But I do want to help, so I'll try to point
you in the right direction.

I believe you're on the right track. As I recall, it is necessary to use
parent/child relationships, and possibly a combination of two related
DataTables to do this, perhaps even a custom View from the DataSet. I know
that's not much, but I'm afraid it's all I have time for right now. In fact,
I should probably go to bed!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Sequence, Selection, ZZZZZZZZzzzzzzzzzzzzzzzzzzzzzzzz.......................


<whittetinternet@earthlink.net> wrote in message
news:1153950896.181772.247630@m73g2000cwd.googlegroups.com...
> Here is what I have now:
> dataView.Sort = dataGridView.SortedColumn.Name + " " +
> (direction == ListSortDirection.Ascending ?
> "ASC " : "DESC ");
>
> Do I need to databind to a dataView with the sort?
>
> Right now I am using a single DataTable for the binding to the grid and
> a second dataTable for the Sales Unit combobox's DataSource.
>
> So the following only sorts on the ID. Would the solution be to put
> both DataTables in a DataSet and then sort on the view with the column
> being sorted being "Parent(SalesUnit).Name"?
>
> whittetinter...@earthlink.net wrote:
>> I also have a problem doing this. It doesn't seem to work out of the
>> box and I'm not sure which method is the best to choose to solve it. I
>> have the DataGridView FAQ and it is great, but in this case it appears
>> that having a DataSource assigned is hurting my options of sorting on a
>> field not assigned to the DataSource's DataTable.
>>
>> I have a DataGridView bound to a DataTable. I then add a
>> DataGridViewComboBoxColumn and this all works. Now when I click this
>> column the sort apprears to sort on the ID instead of the NAME
>> displayed in the combo box.
>> I have
>> cbo.DataPropertyName = "SalesUnitID"
>> cbo.DisplayMember = "NAME"; //Name from the SalesUnit table.
>> cbo.ValueMember = "ID"; //ID from the SalesUnit table.
>>
>> --The e-mail is trash, post your response please:)
>>
>> nvx wrote:
>> > Well, it seems I didn't have set the DataPropertyName correctly. Due to
>> > certain things one letter was in lowercase and everything went wrong.
>> >
>> > Uff, I'm glad it's working... :)
>> >
>> > Kevin, thank you very much for your help.
>> >
>> > With regards
>> > nvx
>> >
>> >
>> > nvx napsal(a):
>> > > I'm sorry, I must have misunderstood.
>> > >
>> > > Yes, the DataGridView is bound to an Access database table. After the
>> > > grid is filled with data, user can add or remove
>> > > DataGridViewComboBoxColumn columns.
>> > >
>> > > Kevin Spencer napsal(a):
>> > >> I meant, are you using a DataSource for the DataGridView columns?
>> > >>
>



Re: Sorting of DataGridViewComboBoxColumn type columns by whittetinternet

whittetinternet
Thu Jul 27 12:22:30 CDT 2006

Happy to receive the help.

The solution with a databound grid that I used was to add an
DataColumn.Expression to the combo box column and use that column to
sort using the click event of the DataGridView column header and set
the dataView.Sort = "MyColumnNAME ASC";

Also, we had a request to display an inserted row in Rows[0] after each
insert. This solution will help solve that too.

Kevin Spencer wrote:
> You'll have to forgive me. It's late, and I've put in a long day (in a long
> series of long days!). In addition, I haven't worked on this particular
> project for awhile, and the DataGridView is one complex critter, so I may be
> a bit lax in my recollection. But I do want to help, so I'll try to point
> you in the right direction.
>
> I believe you're on the right track. As I recall, it is necessary to use
> parent/child relationships, and possibly a combination of two related
> DataTables to do this, perhaps even a custom View from the DataSet. I know
> that's not much, but I'm afraid it's all I have time for right now. In fact,
> I should probably go to bed!
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Chicken Salad Alchemist
>
> Sequence, Selection, ZZZZZZZZzzzzzzzzzzzzzzzzzzzzzzzz.......................
>
>
> <whittetinternet@earthlink.net> wrote in message
> news:1153950896.181772.247630@m73g2000cwd.googlegroups.com...
> > Here is what I have now:
> > dataView.Sort = dataGridView.SortedColumn.Name + " " +
> > (direction == ListSortDirection.Ascending ?
> > "ASC " : "DESC ");
> >
> > Do I need to databind to a dataView with the sort?
> >
> > Right now I am using a single DataTable for the binding to the grid and
> > a second dataTable for the Sales Unit combobox's DataSource.
> >
> > So the following only sorts on the ID. Would the solution be to put
> > both DataTables in a DataSet and then sort on the view with the column
> > being sorted being "Parent(SalesUnit).Name"?
> >
> > whittetinter...@earthlink.net wrote:
> >> I also have a problem doing this. It doesn't seem to work out of the
> >> box and I'm not sure which method is the best to choose to solve it. I
> >> have the DataGridView FAQ and it is great, but in this case it appears
> >> that having a DataSource assigned is hurting my options of sorting on a
> >> field not assigned to the DataSource's DataTable.
> >>
> >> I have a DataGridView bound to a DataTable. I then add a
> >> DataGridViewComboBoxColumn and this all works. Now when I click this
> >> column the sort apprears to sort on the ID instead of the NAME
> >> displayed in the combo box.
> >> I have
> >> cbo.DataPropertyName = "SalesUnitID"
> >> cbo.DisplayMember = "NAME"; //Name from the SalesUnit table.
> >> cbo.ValueMember = "ID"; //ID from the SalesUnit table.
> >>
> >> --The e-mail is trash, post your response please:)
> >>
> >> nvx wrote:
> >> > Well, it seems I didn't have set the DataPropertyName correctly. Due to
> >> > certain things one letter was in lowercase and everything went wrong.
> >> >
> >> > Uff, I'm glad it's working... :)
> >> >
> >> > Kevin, thank you very much for your help.
> >> >
> >> > With regards
> >> > nvx
> >> >
> >> >
> >> > nvx napsal(a):
> >> > > I'm sorry, I must have misunderstood.
> >> > >
> >> > > Yes, the DataGridView is bound to an Access database table. After the
> >> > > grid is filled with data, user can add or remove
> >> > > DataGridViewComboBoxColumn columns.
> >> > >
> >> > > Kevin Spencer napsal(a):
> >> > >> I meant, are you using a DataSource for the DataGridView columns?
> >> > >>
> >