RadListBox Cancel Selection

Thread is closed for posting
2 posts, 0 answers
  1. skokk
    skokk avatar
    1 posts
    Member since:
    Dec 2008

    Posted 11 Dec 2008 Link to this post

    I've been building a testing application as a front-end to an sql database.
    I'm using a RadListBox control as a navigator of the underlying dataset.datatable and under certain circumstances
    I'd like to forbid the user from changing the SelectedIndex.
    I know that I could just disable the RadListBox when these circumstances are met and then re-enable it back when everything is
    in the correct state to keep navigating.
    The thing is that I don't like the look of the disabled state of the control (everything grayed out..).
    As far as I know I could also customize the theme of RadListBox to make the disabled state look identical to the enabled.
    But I'm not sure if this modified theme will override the default themes of all the other Rad Controls I have on the form / solution.

    Anyway, I was looking for a more "by code" solution than repainting the theme.
    The problem is that the RadListBox doesn't have a SelectedIndexChanging event (or something alike) that supports cancellation (just like the regular .NET ListBox).
    I tried using the Enter event to change the focus to another form control (as I did in a previous test with a comboBox) but this doesn't work as expected.

    Any info would be much appreciated
    Thanks in advance
  2. Nick
    Nick avatar
    767 posts

    Posted 12 Dec 2008 Link to this post

    Hello skokk,

    Thank you for contacting us.

    Please see the following work around:

            int prevIndex; 
            bool deactivated = false
            private void radListBox1_SelectedIndexChanged_1(object sender, EventArgs e) 
                if (deactivated) 
                         = prevIndex; 
            private void radButton1_Click_1(object sender, EventArgs e) 
                this.prevIndex = this.radListBox1.SelectedIndex; 
                deactivated = true

    Do not hesitate to write me back if you have more questions.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top