By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

ComboBox - Setting the SelectedIndex - Throwing an error

P: n/a
This line of code had been working with out issue, now its throwing
errors.

In my case I have three items in the ComboBox. If I try to change the
selected index it throw the error.

Earler in the code I check to see if the combobox has any items, if so
then I set it to 0 with out issue.

Then a bit later in the code I try to set it to the last server used.

cboServer.SelectedIndex = cboServer.FindString(sServerName)

I try in in the command window and get the same results.
cboServer.SelectedIndex = 1

Throws this Error:

Run-time exception thrown : System.ArgumentException - Could not bind
to the new display member.
Parameter name: newDisplayMember

I've seen several postings about this error message but none have
anyting to do with the SelectedIndex.

Does anyone have any ideas as to what may be happening?
Any thoughts, ideas would be appreciated.

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi John,

I'm not sure that I can answer your question without a little more
understanding of what is going on. One thing that immediately puzzles me is
your comment about setting the selectedindex directly from the IDE. Unless
you have somehow cleared your itemlist or you only have one item (zero based
index) I don't see the problem with this statement.

Have you tried cboServer.FindString(Trim(sServerName))

Have you tried returning some properties of the cbo immediately before
setting the SelectedIndex?

Rgds,

Phil

<jo********@usa.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
This line of code had been working with out issue, now its throwing
errors.

In my case I have three items in the ComboBox. If I try to change the
selected index it throw the error.

Earler in the code I check to see if the combobox has any items, if so
then I set it to 0 with out issue.

Then a bit later in the code I try to set it to the last server used.

cboServer.SelectedIndex = cboServer.FindString(sServerName)

I try in in the command window and get the same results.
cboServer.SelectedIndex = 1

Throws this Error:

Run-time exception thrown : System.ArgumentException - Could not bind
to the new display member.
Parameter name: newDisplayMember

I've seen several postings about this error message but none have
anyting to do with the SelectedIndex.

Does anyone have any ideas as to what may be happening?
Any thoughts, ideas would be appreciated.

Nov 21 '05 #2

P: n/a
Hi Phil

I have tried returning some properties from the combo box.
I put a break point in the code (on the line of code below) and printed
out a few items such as items.count etc... in the command window.
cboServer.SelectedIndex = cboServer.FindString(sServerName)

I have tried finding the server names in the combo box.

? cboServer.FindString("ServerOne")
Return 0

? cboServer.FindString("ServerTwo")
Returns 1

? cboServer.FindString("ServerThree")
Returns 2

When I set index I get the error
cboServer.SelectedIndex = 1

The combo box is loaded with the informaiton I want.

When I try to set the index of the combobox I get that error.

If I comment out the "cboServer.SelectedIndex =
cboServer.FindString(sServerName)" the applicaiton runs and you are
able to use the combo box.

Its very strange... Yesterday I was using the application and it
worked fine. I came back a few minutes later to use that application
and found that was throwing erros when it loaded?
I checked out the source code and begain testing and found that it was
complaining about setting the Selected Index?

This should work...

I tried setting the index to something that was not valid for the list.
cboServer.SelectedIndex = 23

I got the expected message complaining about an invalid index value.

Not sure where to look for answers.
John

Nov 21 '05 #3

P: n/a
Hi Phil

I have tried returning some properties from the combo box.
I put a break point in the code (on the line of code below) and printed
out a few items such as items.count etc... in the command window.
cboServer.SelectedIndex = cboServer.FindString(sServerName)

I have tried finding the server names in the combo box.

? cboServer.FindString("ServerOne")
Return 0

? cboServer.FindString("ServerTwo")
Returns 1

? cboServer.FindString("ServerThree")
Returns 2

When I set index I get the error
cboServer.SelectedIndex = 1

The combo box is loaded with the informaiton I want.

When I try to set the index of the combobox I get that error.

If I comment out the "cboServer.SelectedIndex =
cboServer.FindString(sServerName)" the applicaiton runs and you are
able to use the combo box.

Its very strange... Yesterday I was using the application and it
worked fine. I came back a few minutes later to use that application
and found that was throwing erros when it loaded?
I checked out the source code and begain testing and found that it was
complaining about setting the Selected Index?

This should work...

I tried setting the index to something that was not valid for the list.
cboServer.SelectedIndex = 23

I got the expected message complaining about an invalid index value.

Not sure where to look for answers.
John

Nov 21 '05 #4

P: n/a
John,

I know it 'shouldn't' make any difference and it is the same thing but an
additional step, (you may have tried this!).

Dim intRet as integer
intRet = cboServer.FindString(sServerName)
cboServer.SelectedIndex = intRet

Is it the same result?

Like you, the problem isn't jumping out at me.........and especially as IT
WAS working (Grrrrrr). Good luck ;-)

Phil
<jo********@usa.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi Phil

I have tried returning some properties from the combo box.
I put a break point in the code (on the line of code below) and printed
out a few items such as items.count etc... in the command window.
cboServer.SelectedIndex = cboServer.FindString(sServerName)

I have tried finding the server names in the combo box.

? cboServer.FindString("ServerOne")
Return 0

? cboServer.FindString("ServerTwo")
Returns 1

? cboServer.FindString("ServerThree")
Returns 2

When I set index I get the error
cboServer.SelectedIndex = 1

The combo box is loaded with the informaiton I want.

When I try to set the index of the combobox I get that error.

If I comment out the "cboServer.SelectedIndex =
cboServer.FindString(sServerName)" the applicaiton runs and you are
able to use the combo box.

Its very strange... Yesterday I was using the application and it
worked fine. I came back a few minutes later to use that application
and found that was throwing erros when it loaded?
I checked out the source code and begain testing and found that it was
complaining about setting the Selected Index?

This should work...

I tried setting the index to something that was not valid for the list.
cboServer.SelectedIndex = 23

I got the expected message complaining about an invalid index value.

Not sure where to look for answers.
John

Nov 21 '05 #5

P: n/a
John,

Where are you setting this and is there more code around.

By instance setting the selected index inside the selected index change
event, gives mostly a lot of trouble if there is not a protection that the
set itself throws an selected index change event.

I hope this helps,

Cor
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.