Click here to Skip to main content
15,904,416 members
Home / Discussions / C#
   

C#

 
AnswerRe: referencing a control from a string [modified] Pin
xcorporation19-May-09 11:05
xcorporation19-May-09 11:05 
GeneralRe: referencing a control from a string Pin
Tom Wright20-May-09 8:45
Tom Wright20-May-09 8:45 
QuestionRegex question Pin
Harvey Saayman19-May-09 8:46
Harvey Saayman19-May-09 8:46 
AnswerRe: Regex question Pin
led mike19-May-09 8:54
led mike19-May-09 8:54 
AnswerRe: Regex question Pin
Noctris19-May-09 8:56
Noctris19-May-09 8:56 
QuestionColor Convertor Pin
Rafone19-May-09 8:34
Rafone19-May-09 8:34 
AnswerRe: Color Convertor Pin
led mike19-May-09 8:50
led mike19-May-09 8:50 
QuestionComboBox AutoComplete with id value Pin
Noctris19-May-09 6:28
Noctris19-May-09 6:28 
Hi Everyone,

I have a combobox that i need to populate with a datasource from my database. Because i want to make this autocomplete AND have the possibility to enter new things, i have done the following:



Private void LoadAuthors()
{

cmbAuthors.DataSource = Dataset;
cmbAuthors.DisplayMember = "Name";
cmbAuthors.ValueMember = "Id";
cmdAuthors.AutoCompleteCustomSource = AutoCompleteStringCollectionIMadeFromTheDataSet;
cmbAuthors.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cmbAuthors.AutoCompleteSource = AutoCompleteSource.CustomSource;

}


And all is well in Autocomplete land and datasource land.. however...

to find out if they entered a new name ( and i need to pop up a form to complete extra info), i have a handler for the "leave" event on the combobox:

private void cmbAuthors_Leave(object sender, EventArgs e)
        {
            if (cmbAuthors.SelectedValue != null)
            {
                MessageBox.Show("We know the dude...");
            }
            else
            {
                MessageBox.Show("Who's that ? better make a new one !");
// FrmAuthorDetails FrmAddNewAuthor = new FrmAuthorDetails();
            }
        }


now the problem is:

When you leave the combobox, the selectedvalue always is null, i get the "who's that" message, and when i click ok to that THEN the selectedindex event fires on the combobox (and thus only getting the required data to make this check)

Is there any way to make sure the selectedindex event is fired first or manually fire the autocomplete so it will complete BEFORE, it actually fires the leave event ?

Any other intelligent solution i could not think of or have not found on google codeproject is welcome too obviously Wink | ;-)

Do Or Don't, there is no "try catch ex as exception end try"

AnswerRe: ComboBox AutoComplete with id value Pin
musefan19-May-09 6:42
musefan19-May-09 6:42 
GeneralRe: ComboBox AutoComplete with id value Pin
Noctris19-May-09 7:06
Noctris19-May-09 7:06 
AnswerRe: ComboBox AutoComplete with id value Pin
Noctris19-May-09 9:37
Noctris19-May-09 9:37 
QuestionToolstrip font combobox Pin
malcomhfc19-May-09 5:01
malcomhfc19-May-09 5:01 
AnswerRe: Toolstrip font combobox Pin
0x3c019-May-09 5:13
0x3c019-May-09 5:13 
GeneralRe: Toolstrip font combobox Pin
malcomhfc19-May-09 5:21
malcomhfc19-May-09 5:21 
GeneralRe: Toolstrip font combobox Pin
0x3c019-May-09 5:40
0x3c019-May-09 5:40 
GeneralRe: Toolstrip font combobox [modified] Pin
malcomhfc19-May-09 5:44
malcomhfc19-May-09 5:44 
GeneralRe: Toolstrip font combobox Pin
musefan19-May-09 6:16
musefan19-May-09 6:16 
GeneralRe: Toolstrip font combobox Pin
musefan19-May-09 6:36
musefan19-May-09 6:36 
GeneralRe: Toolstrip font combobox Pin
malcomhfc19-May-09 7:20
malcomhfc19-May-09 7:20 
GeneralRe: Toolstrip font combobox Pin
0x3c019-May-09 10:18
0x3c019-May-09 10:18 
GeneralRe: Toolstrip font combobox Pin
0x3c019-May-09 6:37
0x3c019-May-09 6:37 
AnswerRe: Toolstrip font combobox Pin
blackhattrick19-May-09 8:34
blackhattrick19-May-09 8:34 
GeneralRe: Toolstrip font combobox Pin
malcomhfc19-May-09 8:40
malcomhfc19-May-09 8:40 
QuestionClass Library / name space Question Pin
gmhanna19-May-09 4:48
gmhanna19-May-09 4:48 
AnswerRe: Class Library / name space Question Pin
OriginalGriff19-May-09 4:50
mveOriginalGriff19-May-09 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.