Difference between String and Value

4 visualizaciones (últimos 30 días)
Aj
Aj el 2 de Nov. de 2017
Editada: Stephen23 el 2 de Nov. de 2017
I am new working with GUIs. My Question is, when I use String and when i use value? I dont understand the difference.
set(handles.staticText1, ' String')

Respuesta aceptada

Stephen23
Stephen23 el 2 de Nov. de 2017
Editada: Stephen23 el 2 de Nov. de 2017
I guess you are asking about something like uicontrol objects. The difference is simple:
  • The string property is simply what is displayed on a GUI object, eg the label on a button.
  • The value property indicates the state of that object, e.g. whether the button depressed or not.
You should always read the documentation carefully each time you use any uicontrol object:
  1 comentario
Aj
Aj el 2 de Nov. de 2017
ok, that was easy to understand. Thanks mate!!!

Iniciar sesión para comentar.

Más respuestas (2)

Jan
Jan el 2 de Nov. de 2017
Editada: Jan el 2 de Nov. de 2017
The 'String' property contains the string (character vector), which is displayed in the GUI. The 'Value' contains a numerical value, e.g. 1 or 0 for a toggle button or check box to determine, if the control is enabled or disabled currently. For a slider it is the current value between the min and max values. For a listbox, 'Value' contains the selected rows.
While the 'String' is usually fixed, the 'Value' depends on the user actions (with exceptions, of course, e.g. if the name of a user selected file is displayed in a button).

Roman Müller-Hainbach
Roman Müller-Hainbach el 2 de Nov. de 2017
Different UI elements have different uses for the 'String' and 'Value' property. in 'uicontrol's these properties behave dependent on the 'Style' you choose ('pushbutton' by default). Things like pushbuttons, textfields probably use the 'String' property to set the displayed string. The 'Value' doesn't always have a function in uicontrols. Checkboxes are an example where this property is used. It controls the state (checked/unchecked) there. As always, read the documentation for the element you are using. The uses for such a property like 'String' and 'Value' may differ a lot for different classes of objects. Feel free to ask more specifically about the element you are using right now.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by