This is a migrated thread and some comments may be shown as answers.

RadListBox Cancel Selection

1 Answer 56 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
skokk
Top achievements
Rank 1
skokk asked on 11 Dec 2008, 01:41 PM
Hi,
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

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 12 Dec 2008, 04:40 PM
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) 
            { 
                this.radListBox1.SelectedIndex 
                     = 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.

Regards,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
skokk
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or