Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Autocomplete combobox selectedvalue returns undefined value
Hi all,
I am pulling my hair out here.
I am trying to implement a dropdown (databound - valuemember and
displaymember) which drops down and has an auto complete. The code
below appears to work okay but when I try and save the value away
using the SelectedValue property it returns "undefined value".

Here is my code:
private void cboPBrokerB_KeyPress(object sender,
system.Windows.Forms.KeyPressEventArgs e)
{
 AutoCompleteCombo_KeyPress(((ComboBox)se
nder),e);
}

private void AutoCompleteCombo_KeyPress(ComboBox cbo,
System.Windows.Forms.KeyPressEventArgs e)
{
if ((cbo.DropDownStyle ==
ComboBoxStyle.DropDown)&&(cbo.DroppedDown==false))
cbo.DroppedDown = true;

if (char.IsControl(e.KeyChar))
return;

string ToFind = cbo.Text.Substring(0, cbo.SelectionStart) +
e.KeyChar;
int Index = cbo.FindStringExact(ToFind);

if (Index == -1)
Index = cbo.FindString(ToFind);
if (Index == -1)
{
e.Handled = true;
return;
}

cbo.SelectedIndex = Index;
cbo.SelectionStart = ToFind.Length;
cbo.SelectionLength = cbo.Text.Length - cbo.SelectionStart;
e.Handled = true;
}

Any assistance would be greatly appreciated!
Thanks in advance - Brett!

Report this thread to moderator Post Follow-up to this message
Old Post
Brotto
12-10-04 08:58 PM


Re: Autocomplete combobox selectedvalue returns undefined value
Is that you fill the combobox with a datasouce or fill it by adding item to 
its item collection?

Report this thread to moderator Post Follow-up to this message
Old Post
tug
12-29-04 11:17 AM


Re: Autocomplete combobox selectedvalue returns undefined value
Did you find a solution for this?  I would be very interested in hearing it 
if you did!

Thanks,

Kevin

Report this thread to moderator Post Follow-up to this message
Old Post
DCPUD
01-21-05 01:32 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:37 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.