Click here to Skip to main content
15,880,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: Voice conference Pin
yesu prakash25-Feb-09 19:28
yesu prakash25-Feb-09 19:28 
GeneralRe: Voice conference Pin
N a v a n e e t h25-Feb-09 21:05
N a v a n e e t h25-Feb-09 21:05 
GeneralRe: Voice conference Pin
yesu prakash27-Feb-09 1:38
yesu prakash27-Feb-09 1:38 
AnswerRe: [Message Deleted] Pin
yesu prakash26-Feb-09 23:52
yesu prakash26-Feb-09 23:52 
Questionview .doc file in the same format Pin
devinaren25-Feb-09 15:38
devinaren25-Feb-09 15:38 
AnswerRe: view .doc file in the same format Pin
Avi Farah25-Feb-09 16:38
Avi Farah25-Feb-09 16:38 
AnswerRe: view .doc file in the same format Pin
Christian Graus25-Feb-09 18:11
protectorChristian Graus25-Feb-09 18:11 
Questionindex += 1 equals index + 2 ? [modified] Pin
Lodeclaw25-Feb-09 11:59
Lodeclaw25-Feb-09 11:59 
private void ComboBox_KeyDown(object sender, KeyEventArgs e)
        {
            this.ComboBox.DroppedDown = true;
            if (e.KeyCode == Keys.Up && this.ComboBox.SelectedIndex != 0)
            {
                this.ComboBox.SelectedIndex -= 1;
                return;
            }
            if (e.KeyCode == Keys.Down && this.ComboBox.SelectedIndex != this.ComboBox.Items.Count - 1)
            {
                this.ComboBox.SelectedIndex += 1;
                return;
            }
            this.ComboBox.SelectedItem = this.ComboBox.Text + "%";
        }

Hello folks. I have this event set up to search/skip to the contents of a ComboBox by the text entered, however I want to make sure I can still use the up and down keys functionality... My problem is when I run this code in my project and press the up or down keys in the ComboBox my selection moves up or down two spaces rather than one. What am I missing?

Thanks in advance!

EDIT: Sorry, the code actually was slightly wrong due to my experimenting before posting. It's fixed how I meant it to be and the problem persists. The old code was as follows and has the same outcome:
private void ComboBox_KeyDown(object sender, KeyEventArgs e)
        {
            this.ComboBox.DroppedDown = true;
            if (e.KeyCode == Keys.Up && this.ComboBox.SelectedIndex != 0)
            {
                this.ComboBox.SelectedIndex = this.ComboBox.SelectedIndex - 1;
                return;
            }
            if (e.KeyCode == Keys.Down && this.ComboBox.SelectedIndex != this.ComboBox.Items.Count - 1)
            {
                this.ComboBox.SelectedIndex = this.ComboBox.SelectedIndex + 1;
                return;
            }
            this.ComboBox.SelectedItem = this.ComboBox.Text + "%";
        }


modified on Wednesday, February 25, 2009 6:10 PM

AnswerRe: index += 1 equals index + 2 ? Pin
Lodeclaw25-Feb-09 12:19
Lodeclaw25-Feb-09 12:19 
GeneralRe: index += 1 equals index + 2 ? Pin
Calin Tatar25-Feb-09 12:24
Calin Tatar25-Feb-09 12:24 
GeneralRe: index += 1 equals index + 2 ? Pin
Lodeclaw25-Feb-09 12:25
Lodeclaw25-Feb-09 12:25 
QuestionTransfer a txt file Pin
bar300025-Feb-09 11:05
bar300025-Feb-09 11:05 
AnswerRe: Transfer a txt file Pin
Alan Balkany25-Feb-09 11:18
Alan Balkany25-Feb-09 11:18 
GeneralRe: Transfer a txt file Pin
bar300025-Feb-09 11:28
bar300025-Feb-09 11:28 
AnswerRe: Transfer a txt file Pin
Christian Graus25-Feb-09 11:27
protectorChristian Graus25-Feb-09 11:27 
GeneralRe: Transfer a txt file Pin
bar300025-Feb-09 11:35
bar300025-Feb-09 11:35 
GeneralRe: Transfer a txt file Pin
vaghelabhavesh25-Feb-09 13:49
vaghelabhavesh25-Feb-09 13:49 
AnswerRe: Transfer a txt file Pin
Luc Pattyn25-Feb-09 11:45
sitebuilderLuc Pattyn25-Feb-09 11:45 
AnswerRe: Transfer a txt file Pin
harold aptroot25-Feb-09 12:54
harold aptroot25-Feb-09 12:54 
AnswerRe: Transfer a txt file Pin
Luc Pattyn25-Feb-09 13:15
sitebuilderLuc Pattyn25-Feb-09 13:15 
AnswerRe: Transfer a txt file [modified] Pin
Megidolaon25-Feb-09 21:59
Megidolaon25-Feb-09 21:59 
QuestionRTF Fields have a gap between them when placed against each other. Pin
Ryan Esteves25-Feb-09 9:47
professionalRyan Esteves25-Feb-09 9:47 
GeneralRe: RTF Fields have a gap between them when placed against each other. Pin
Lodeclaw25-Feb-09 12:30
Lodeclaw25-Feb-09 12:30 
GeneralRe: RTF Fields have a gap between them when placed against each other. Pin
Ryan Esteves26-Feb-09 4:19
professionalRyan Esteves26-Feb-09 4:19 
AnswerRe: RTF Fields have a gap between them when placed against each other. Pin
Ryan Esteves3-Mar-09 6:00
professionalRyan Esteves3-Mar-09 6:00 

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.