Search code examples
c#devexpressdevexpress-windows-ui

Adding some values to spin button in devexpress


I want baudrates like 2400, 4800,...,57600, 115200 to be selectable in a spin button control.

I can't see a way to do this in devexpress spin button control, since (in my understandig) it's only possible to set a whole range of values (e.g. 2400,2401,2402,...57599,57600). Am I wrong? Is there a better way in devexpress, to let the user set a baudrate?


Solution

  • The Event you are looking for is called "Spin"

    Set Min to 2400, Max to 115200

    Then put your logic in the Spin Event Code:

    private void spinEdit1_Properties_Spin(object sender, DevExpress.XtraEditors.Controls.SpinEventArgs e)
    {
        if (e.IsSpinUp)
        {
            spinEdit1.EditValue = 4800;
            e.Handled = true;
        }
        else
        {
            spinEdit1.EditValue = 2400;
            e.Handled = true;
        }
    }
    

    Note: this example only goes up to 4800 and down to 2400 ,but you get the Idea. You can use some of the Code of nempoBu4 as well combined with this one :)