Click here to Skip to main content
15,914,070 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem with SelectedIndexChanged method Pin
Martin#9-Jul-07 21:55
Martin#9-Jul-07 21:55 
GeneralRe: Problem with SelectedIndexChanged method Pin
Rajesh R Subramanian9-Jul-07 22:00
professionalRajesh R Subramanian9-Jul-07 22:00 
GeneralRe: Problem with SelectedIndexChanged method Pin
Martin#9-Jul-07 22:02
Martin#9-Jul-07 22:02 
GeneralRe: Problem with SelectedIndexChanged method Pin
Rajesh R Subramanian9-Jul-07 22:08
professionalRajesh R Subramanian9-Jul-07 22:08 
QuestionRe: Problem with SelectedIndexChanged method Pin
Rajesh R Subramanian9-Jul-07 23:45
professionalRajesh R Subramanian9-Jul-07 23:45 
AnswerRe: Problem with SelectedIndexChanged method Pin
Martin#9-Jul-07 23:56
Martin#9-Jul-07 23:56 
GeneralRe: Problem with SelectedIndexChanged method Pin
Rajesh R Subramanian10-Jul-07 0:00
professionalRajesh R Subramanian10-Jul-07 0:00 
GeneralRe: Problem with SelectedIndexChanged method Pin
Martin#10-Jul-07 0:19
Martin#10-Jul-07 0:19 
Hello,

brahmma wrote:
And the SelectedIndexChanged will be called even if the user selects the same item again, which sucks

So true!

brahmma wrote:
So, do I need to check manually if the user has selected a different item every time and then execute my code?

I think in your special case, yes!

brahmma wrote:
If yes, then why do we have event handlers?

I guess this statetment comes out of frustration.

An other possibility is, you do what MS was not willed todo:
inherit your own combobox, like this:
public class SpecialComboBox : System.Windows.Forms.ComboBox
{
    private bool init = true;
    private int oldIndex = 0;

    public SpecialComboBox()
    {
    }

    protected override void OnSelectedIndexChanged(EventArgs e)
    {
        if((oldIndex!=this.SelectedIndex)|| init)
        {
            init=false;
            oldIndex = SelectedIndex;

            base.OnSelectedIndexChanged (e);
        }
    }
}

This should do it!

All the best,

Martin

GeneralRe: Problem with SelectedIndexChanged method Pin
Muhammad Gouda10-Jul-07 0:51
Muhammad Gouda10-Jul-07 0:51 
GeneralRe: Problem with SelectedIndexChanged method Pin
Martin#10-Jul-07 1:13
Martin#10-Jul-07 1:13 
GeneralRe: Problem with SelectedIndexChanged method Pin
Rajesh R Subramanian10-Jul-07 0:51
professionalRajesh R Subramanian10-Jul-07 0:51 
GeneralRe: Problem with SelectedIndexChanged method [modified] Pin
Martin#10-Jul-07 1:12
Martin#10-Jul-07 1:12 
QuestionDetect child form client area even if maximized. Pin
swjam9-Jul-07 21:31
swjam9-Jul-07 21:31 
Questionoutlook progrmaing using c# Pin
gihankoli9-Jul-07 21:27
gihankoli9-Jul-07 21:27 
AnswerRe: outlook programing using c# Pin
originSH9-Jul-07 22:04
originSH9-Jul-07 22:04 
QuestionChanging date format Pin
pmartike9-Jul-07 21:12
pmartike9-Jul-07 21:12 
AnswerRe: Changing date format Pin
Muhammad Gouda9-Jul-07 21:42
Muhammad Gouda9-Jul-07 21:42 
AnswerRe: Changing date format Pin
Harini N K9-Jul-07 21:55
Harini N K9-Jul-07 21:55 
GeneralRe: Changing date format Pin
pmartike9-Jul-07 22:07
pmartike9-Jul-07 22:07 
AnswerRe: Changing date format Pin
Md Mustafa9-Jul-07 22:41
Md Mustafa9-Jul-07 22:41 
GeneralRe: Changing date format Pin
pmartike10-Jul-07 0:27
pmartike10-Jul-07 0:27 
GeneralRe: Changing date format Pin
Vikram A Punathambekar10-Jul-07 0:35
Vikram A Punathambekar10-Jul-07 0:35 
GeneralRe: Changing date format Pin
pmartike10-Jul-07 1:58
pmartike10-Jul-07 1:58 
GeneralRe: Changing date format Pin
PIEBALDconsult10-Jul-07 8:28
mvePIEBALDconsult10-Jul-07 8:28 
GeneralRe: Changing date format Pin
pmartike10-Jul-07 21:25
pmartike10-Jul-07 21: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.