strange format problem

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

I ma stupped.
int idx = viewRegexOptionBindingSource.Find("regexoption",
textBoxRegexOption.Text); // works , no problem here

if (idx < 0) idx = 0;

bFormLoading = true;

regexOptionListBox.SetSelected(idx, true);

int idx2 = viewRegexCategoryBindingSource.Find("regexcategory",
textBoxRegexCategory.Text); //oops I got error:
Input string was not in a correct format.


and I don't see any difference in first find from the last find above,

I have tried retype the statment from scratch, but I sitll have the same
problem.
If I mis-type the search string regexcategory to something else like adding
a letter a, I will get as message of
DataMember property 'regexcategorya' cannot be found on the DataSource.
 
Is "regexcategory" a string? The BindingSource.Find() method accepts
an object as the second parameter. I don't know how it is implemented
internally: it *might* attempt to use the relevant TypeConverted to
convert your input-string to the desired type, which might be causing
the issue; it might just want the correct type itself.

Marc
 
yes, "regexcategory" is string literal. as a matter fact, it expects Unicode
string.
I believe I am giving Unicode string.

I am confounded by the fact the similar statement works for different
binding source but not for the 2nd binding source.

I even tried
string sRC = "regexcategory";
int idx2 = viewRegexCategoryBindingSource.Find(sRC,
this.textBoxRegexCategory.Text);

but I get the exact same message

BTW I am using the datasource.Find 2nd form with arguments as System.String
followed by object key


Of course if there is another way to find out the index of the
regexCategoryListBox item that matches textBoxRegexCategory.Text, I would
love to use that and we don't have to sweat on this anomaly .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top