Connecting Tech Pros Worldwide Forums | Help | Site Map

I can't sort my combo box. Please Help!

raj
Guest
 
Posts: n/a
#1: Nov 22 '05
When I try to sort my combo box I get the following error.

"Cannot sort a ComboBox that has a DataSource set. Sort the data using the
underlying data model."

--------------------------------THe code is given below.
String strSQL;

strSQL = "SELECT .......... WHERE C.Client = '" +
this.cboClient.SelectedValue + "' ";
userTable = manager.GetDataTable(strSQL,"userList");

cmbUserList.DataSource = userTable;
cmbUserList.DisplayMember = "FollowUpPerson";
cmbUserList.ValueMember = "FollowUpPerson";

cmbUserList.SelectedIndex = -1;
cmbUserList.Sorted = true;
------------------------------------------------
I do really appreciate any ideas or sugessions.

Thanks

raj

John Kn [MS]
Guest
 
Posts: n/a
#2: Nov 22 '05

re: I can't sort my combo box. Please Help!


Raj,
The combobox will not fill if it has 'sorted' preselected in the design
process.

--------------------[color=blue]
>Thread-Topic: I can't sort my combo box. Please Help!
>thread-index: AcS/xvw8xLfcJGSzQJKvGzE1Rk/XNQ==
>X-WBNR-Posting-Host: 203.28.214.209
>From: =?Utf-8?B?cmFq?= <raj@discussions.microsoft.com>
>Subject: I can't sort my combo box. Please Help!
>Date: Sun, 31 Oct 2004 19:58:02 -0800
>Lines: 24
>Message-ID: <0F4FE28C-F44E-4707-8D79-B4EFBDC72123@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.general
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:150745
>X-Tomcat-NG: microsoft.public.dotnet.general
>
>When I try to sort my combo box I get the following error.
>
>"Cannot sort a ComboBox that has a DataSource set. Sort the data using the
>underlying data model."
>
>--------------------------------THe code is given below.
>String strSQL;
>
>strSQL = "SELECT .......... WHERE C.Client = '" +
>this.cboClient.SelectedValue + "' ";
>userTable = manager.GetDataTable(strSQL,"userList");
>
>cmbUserList.DataSource = userTable;
>cmbUserList.DisplayMember = "FollowUpPerson";
>cmbUserList.ValueMember = "FollowUpPerson";
>
>cmbUserList.SelectedIndex = -1;
>cmbUserList.Sorted = true;
>------------------------------------------------
>I do really appreciate any ideas or sugessions.
>
>Thanks
>
>raj
>[/color]

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl {\f0\fnil\fprq2\fcharset0
MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\f0\fs20 Cheers,\par
\par
johnKn [MS-SDK]\par
\par
\par
\par
-Please do not send email directly to this alias. This alias is for \par
newsgroup purposes only\par
\par
-This posting is provided "AS IS" with no warranties, and confers no
rights.\par
\par
-To provide additional feedback about your community experience please send
\par
e-mail to: sdkcomm@microsoft.com\par
\f1\par
}

raj
Guest
 
Posts: n/a
#3: Nov 22 '05

re: I can't sort my combo box. Please Help!


Hi John Kn
No. the combobox field is not preselected. It is setted to 'FALSE'.
U'r correct it will not get populated if I selected to 'TRUE'.
But my combo box is get populated (As it SORT's seleted to 'FALSE') but I
can't sort at the moment. Do u have any suggestions? I'm trying to explicitly
code as 'cmbUserList.Sorted = true;' This will crashes my aplication with
error message.

Thanks
raj

"John Kn [MS]" wrote:
[color=blue]
> Raj,
> The combobox will not fill if it has 'sorted' preselected in the design
> process.
>
> --------------------[color=green]
> >Thread-Topic: I can't sort my combo box. Please Help!
> >thread-index: AcS/xvw8xLfcJGSzQJKvGzE1Rk/XNQ==
> >X-WBNR-Posting-Host: 203.28.214.209
> >From: =?Utf-8?B?cmFq?= <raj@discussions.microsoft.com>
> >Subject: I can't sort my combo box. Please Help!
> >Date: Sun, 31 Oct 2004 19:58:02 -0800
> >Lines: 24
> >Message-ID: <0F4FE28C-F44E-4707-8D79-B4EFBDC72123@microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.dotnet.general
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:150745
> >X-Tomcat-NG: microsoft.public.dotnet.general
> >
> >When I try to sort my combo box I get the following error.
> >
> >"Cannot sort a ComboBox that has a DataSource set. Sort the data using the
> >underlying data model."
> >
> >--------------------------------THe code is given below.
> >String strSQL;
> >
> >strSQL = "SELECT .......... WHERE C.Client = '" +
> >this.cboClient.SelectedValue + "' ";
> >userTable = manager.GetDataTable(strSQL,"userList");
> >
> >cmbUserList.DataSource = userTable;
> >cmbUserList.DisplayMember = "FollowUpPerson";
> >cmbUserList.ValueMember = "FollowUpPerson";
> >
> >cmbUserList.SelectedIndex = -1;
> >cmbUserList.Sorted = true;
> >------------------------------------------------
> >I do really appreciate any ideas or sugessions.
> >
> >Thanks
> >
> >raj
> >[/color]
>
> {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl {\f0\fnil\fprq2\fcharset0
> MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}}
> {\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\f0\fs20 Cheers,\par
> \par
> johnKn [MS-SDK]\par
> \par
> \par
> \par
> -Please do not send email directly to this alias. This alias is for \par
> newsgroup purposes only\par
> \par
> -This posting is provided "AS IS" with no warranties, and confers no
> rights.\par
> \par
> -To provide additional feedback about your community experience please send
> \par
> e-mail to: sdkcomm@microsoft.com\par
> \f1\par
> }
>
>[/color]
Cor Ligthert
Guest
 
Posts: n/a
#4: Nov 22 '05

re: I can't sort my combo box. Please Help!


Raj,

As the message tells, do you have when you use the datasource have to use a
sorted datasource, what is very easy to do.

Typed here so watch typos

DataView dv = new DataView(userTable);
dv.Sort = "FollowUpPerson";
cmbUserList.DataSource = dv;[color=blue][color=green][color=darkred]
>> >cmbUserList.DisplayMember = "FollowUpPerson";
>> >cmbUserList.ValueMember = "FollowUpPerson";[/color][/color][/color]

I hope this helps?

Cor


C-Services Holland b.v.
Guest
 
Posts: n/a
#5: Nov 22 '05

re: I can't sort my combo box. Please Help!


raj wrote:
[color=blue]
> When I try to sort my combo box I get the following error.
>
> "Cannot sort a ComboBox that has a DataSource set. Sort the data using the
> underlying data model."
>
> --------------------------------THe code is given below.
> String strSQL;
>
> strSQL = "SELECT .......... WHERE C.Client = '" +
> this.cboClient.SelectedValue + "' ";
> userTable = manager.GetDataTable(strSQL,"userList");
>
> cmbUserList.DataSource = userTable;
> cmbUserList.DisplayMember = "FollowUpPerson";
> cmbUserList.ValueMember = "FollowUpPerson";
>
> cmbUserList.SelectedIndex = -1;
> cmbUserList.Sorted = true;
> ------------------------------------------------
> I do really appreciate any ideas or sugessions.
>
> Thanks
>
> raj[/color]

Why not simply sort in the SQL query (order by FolowUpPerson)?

Rinze
Patrick
Guest
 
Posts: n/a
#6: Nov 22 '05

re: I can't sort my combo box. Please Help!



You can also just sort on the .DefaultView property of the datatable,
instead of creating a new dataview object.

"Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
news:e%23OAkL%23vEHA.3080@TK2MSFTNGP12.phx.gbl...[color=blue]
> Raj,
>
> As the message tells, do you have when you use the datasource have to use
> a sorted datasource, what is very easy to do.
>
> Typed here so watch typos
>
> DataView dv = new DataView(userTable);
> dv.Sort = "FollowUpPerson";
> cmbUserList.DataSource = dv;[color=green][color=darkred]
>>> >cmbUserList.DisplayMember = "FollowUpPerson";
>>> >cmbUserList.ValueMember = "FollowUpPerson";[/color][/color]
>
> I hope this helps?
>
> Cor
>[/color]


raj
Guest
 
Posts: n/a
#7: Nov 22 '05

re: I can't sort my combo box. Please Help!


Hi
It works now.
I would like to thanks John, Cor Ligthert. Patrick and C-Serveces Holland,
for assisting me to solve this problem. Once again, many thanks.

Cheers

raj


"C-Services Holland b.v." wrote:
[color=blue]
> raj wrote:
>[color=green]
> > When I try to sort my combo box I get the following error.
> >
> > "Cannot sort a ComboBox that has a DataSource set. Sort the data using the
> > underlying data model."
> >
> > --------------------------------THe code is given below.
> > String strSQL;
> >
> > strSQL = "SELECT .......... WHERE C.Client = '" +
> > this.cboClient.SelectedValue + "' ";
> > userTable = manager.GetDataTable(strSQL,"userList");
> >
> > cmbUserList.DataSource = userTable;
> > cmbUserList.DisplayMember = "FollowUpPerson";
> > cmbUserList.ValueMember = "FollowUpPerson";
> >
> > cmbUserList.SelectedIndex = -1;
> > cmbUserList.Sorted = true;
> > ------------------------------------------------
> > I do really appreciate any ideas or sugessions.
> >
> > Thanks
> >
> > raj[/color]
>
> Why not simply sort in the SQL query (order by FolowUpPerson)?
>
> Rinze
>[/color]
Closed Thread