How to pick an integer in a box using up and down arrows in a gui

1 vue (au cours des 30 derniers jours)
Douglas Anderson
Douglas Anderson le 5 Fév 2014
Commenté : Image Analyst le 5 Fév 2014
Hello,
I would like to be able to choose, in a gui, a number from, say, 1 to 10. Listbox shows them all, which I don't want, and dropdown also will show them when you drop. Is a slider the only way to do this? Typical guis, like for how many tickets you want, etc., have an up and down arrow to increase the number in the box (non-editable so the user can't put in something like a letter).
This may be obvious, but I am not sure how this is implemented.
Thanks!
Doug

Réponse acceptée

Amit
Amit le 5 Fév 2014
Modifié(e) : Amit le 5 Fév 2014
You can use button with symbols + or -, and add functions like adding or subtracting as a feature.
Something like this (very crude version)
  3 commentaires
Amit
Amit le 5 Fév 2014
Most definitely. You said box so I simply used unenabled editbox. But you can use static text box. The code format will still be the same.
Amit
Amit le 5 Fév 2014
For shorter boxes, you can use + and - type buttons on the right and left hand sides, respectively. That might appeal better.

Connectez-vous pour commenter.

Plus de réponses (1)

ES
ES le 5 Fév 2014
If you are really a perfectionist and want button with symbols ^ for up and the inverted ^ for down, you can use cData property of the button.
1. Make an image of ^ which you want to use for the GUI up button [you may crop it from some source)
2. Read the image in matlab using ImMatrix=imread('image.jpg');
3. In the cData property of the button, type ImMatrix and, the image matrix is absolutely copied to the button.
Your button becomes more authentic. Remove any text on top of the button, and use it. This is completely portable, as in, you need not carry the images of up an ddown arrows!
  1 commentaire
Image Analyst
Image Analyst le 5 Fév 2014
Official Mathworks reference:
How do I display an image on a GUI component (eg. pushbutton)?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by