Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
Question[Message Deleted] Pin
sridhar88725-Feb-09 18:16
sridhar88725-Feb-09 18:16 
AnswerRe: How to solve APPLICATION.EXE ERROR in C#.NET??? Pin
Christian Graus25-Feb-09 18:19
protectorChristian Graus25-Feb-09 18:19 
GeneralRe: How to solve APPLICATION.EXE ERROR in C#.NET??? Pin
dan!sh 25-Feb-09 18:41
professional dan!sh 25-Feb-09 18:41 
GeneralRe: How to solve APPLICATION.EXE ERROR in C#.NET??? Pin
Christian Graus25-Feb-09 18:48
protectorChristian Graus25-Feb-09 18:48 
Question[Message Deleted] Pin
sridhar88725-Feb-09 18:03
sridhar88725-Feb-09 18:03 
AnswerRe: How to solve APPLICATION.EXE ERROR in C#.NET??? Pin
Christian Graus25-Feb-09 18:09
protectorChristian Graus25-Feb-09 18:09 
JokeRe: How to solve APPLICATION.EXE ERROR in C#.NET??? Pin
Xmen Real 25-Feb-09 20:06
professional Xmen Real 25-Feb-09 20:06 
QuestionParse SQL code in C# Pin
aaCog25-Feb-09 17:21
aaCog25-Feb-09 17:21 
AnswerRe: Parse SQL code in C# Pin
N a v a n e e t h25-Feb-09 17:32
N a v a n e e t h25-Feb-09 17:32 
Question[Message Deleted] Pin
yesu prakash25-Feb-09 16:47
yesu prakash25-Feb-09 16:47 
AnswerRe: Voice conference Pin
N a v a n e e t h25-Feb-09 17:05
N a v a n e e t h25-Feb-09 17:05 
GeneralRe: Voice conference Pin
Christian Graus25-Feb-09 18:10
protectorChristian Graus25-Feb-09 18:10 
General[Message Deleted] Pin
yesu prakash25-Feb-09 18:27
yesu prakash25-Feb-09 18:27 
GeneralRe: Voice conference Pin
Christian Graus25-Feb-09 18:51
protectorChristian Graus25-Feb-09 18:51 
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 

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.