For Each oObj In dataaray.Children
oObj.text = "" ' I would like this to reset to the text in the properties text
Next
reseting the text in a textbox
- grayghost4
- Posts: 187
- Joined: Wednesday 5th December 2018 5:00am
- Location: Marengo, Illinois usa
reseting the text in a textbox
Is there a way to reset the text of a text box to the text assigned in the properties
Re: reseting the text in a textbox
My only suggestion is that you use the .Tag property.
At the start of your program copy initial text to Tag, something like:-
At the start of your program copy initial text to Tag, something like:-
For Each oObj In dataaray.Children
oObj.Tag = oObj.Text ' store initial properties text
Next
Then you can get it back:-For Each oObj In dataaray.Children
oObj.Text = oObj.Tag ' restore the text in the properties text
Next
- grayghost4
- Posts: 187
- Joined: Wednesday 5th December 2018 5:00am
- Location: Marengo, Illinois usa
Re: reseting the text in a textbox
Thanks that worked !
I have a lot to learn
I have a lot to learn
Re: reseting the text in a textbox
The Tag property is often under-used (or over-looked) but its great for poking things away that you might need later.
It often saves you creating a Public variable, and as its a Variant, its very flexible.
It often saves you creating a Public variable, and as its a Variant, its very flexible.
- grayghost4
- Posts: 187
- Joined: Wednesday 5th December 2018 5:00am
- Location: Marengo, Illinois usa
Re: reseting the text in a textbox
It looks like this will also do the same thing. I needed to use "Try" because dataaray has both text and value boxes.
This will leave Tag for other uses
Property Placeholder As String
Return or set the placeholder text, i.e. the text displayed when the Text property is void.
This will leave Tag for other uses
For Each oObj In dataaray.Children
Try oObj.Placeholder = oObj.Text
Next
For Each oObj In dataaray.Children
Try oObj.Clear
Next
TextBox.Placeholder (gb.qt4)Property Placeholder As String
Return or set the placeholder text, i.e. the text displayed when the Text property is void.
-
OnlineQuincunxian
- Posts: 173
- Joined: Sunday 25th June 2017 12:14am
- Location: Western Australia
Re: reseting the text in a textbox
This is a routine that I use to prepare the controls on a form for validation.
The passed container is normally a panel or frame which contains all the 'maintenance' controls.
{text boxes, text areas, combo boxes, checkboxes etc...}
It will then recursivity search for controls and then set their chosen parameters to whatever it is that I need using the
Object.SetProperty & Object.getProperty commands.
This allows you to overcome the limited set of parameters exposed when you examine the child controls.
The main one is to Trim the text input areas as this overcomes a common problem with user input.
The InColour is used to return the display colour of a control back to a standard. In most cases this is black.
As part of a validation routine, I turn the label for the control red if an error is detected to assist the user in
quickly identifying where the error is.
The passed container is normally a panel or frame which contains all the 'maintenance' controls.
{text boxes, text areas, combo boxes, checkboxes etc...}
It will then recursivity search for controls and then set their chosen parameters to whatever it is that I need using the
Object.SetProperty & Object.getProperty commands.
This allows you to overcome the limited set of parameters exposed when you examine the child controls.
The main one is to Trim the text input areas as this overcomes a common problem with user input.
The InColour is used to return the display colour of a control back to a standard. In most cases this is black.
As part of a validation routine, I turn the label for the control red if an error is detected to assist the user in
quickly identifying where the error is.
Public Sub FormPrepareForValidation(InControl As Object, InColor As Integer)
Dim ControlElement As Control
For Each ControlElement In InControl.Children
If ControlElement Is Frame Then FormPrepareForValidation(ControlElement, InColor) ' It may have children so do a recursive search"
If ControlElement Is Panel Then FormPrepareForValidation(ControlElement, InColor) ' It may have children so do a recursive search"
If ControlElement Is Label Then Object.SetProperty(ControlElement, "ForeGround", InColor)
If ControlElement Is TextBox Then Object.SetProperty(ControlElement, "Text", Trim(Object.getProperty(ControlElement, "Text")))
If ControlElement Is TextArea Then Object.SetProperty(ControlElement, "Text", Trim(Object.getProperty(ControlElement, "Text")))
If ControlElement Is RadioButton Then Object.SetProperty(ControlElement, "ForeGround", InColor)
If ControlElement Is CheckBox Then Object.SetProperty(ControlElement, "ForeGround", InColor)
If ControlElement Is TabPanel Then Object.SetProperty(ControlElement, "ForeGround", InColor)
If ControlElement Is TabStrip Then Object.SetProperty(ControlElement, "ForeGround", InColor)
Next
End
This subroutine uses the same concepts to Reset a container's controls, ready to accept new input.
Public Sub FormResetControls(InControl As Container)
Dim ControlElement As Control
Dim ChildControl As Control
Dim TmpInt As Integer
Dim TPanel As TabPanel
Dim TStrip As TabStrip
For Each ControlElement In InControl.Children
If ControlElement Is Frame Then FormResetControls(ControlElement) ' It may have children so do a recursive search
If ControlElement Is Panel Then FormResetControls(ControlElement) ' It may have children so do a recursive search
If ControlElement Is TabPanel Then
TPanel = ControlElement
For TmpInt = 0 To TPanel.Count - 1
FormResetControls(Tpanel[TmpInt]) ' It may have children so do a recursive search
Next
Endif
If ControlElement Is TabStrip Then
TStrip = ControlElement
For TmpInt = 0 To TPanel.Count - 1
FormResetControls(TStrip[TmpInt]) ' It may have children so do a recursive search
Next
Endif
If ControlElement Is TextBox Then Object.SetProperty(ControlElement, "Text", "")
If ControlElement Is TextBox Then Object.SetProperty(ControlElement, "Background", Color.White)
If ControlElement Is TextArea Then Object.SetProperty(ControlElement, "Text", "")
If ControlElement Is TextEditor Then Object.SetProperty(ControlElement, "Text", "")
If ControlElement Is ComboBox Then Object.SetProperty(ControlElement, "Index", 0)
If ControlElement Is ValueBox Then Object.SetProperty(ControlElement, "value", Null)
If ControlElement Is CheckBox Then Object.SetProperty(ControlElement, "value", 0)
If ControlElement Is SpinBox Then Object.SetProperty(ControlElement, "Value", Object.GetProperty(ControlElement, "MinValue"))
Next
Cheers - Quin.
I code therefore I am
I code therefore I am
- Technopeasant
- Posts: 144
- Joined: Saturday 13th July 2019 6:50pm
- Location: Stony Plain, Alberta, Canada
- Contact:
Re: reseting the text in a textbox
I had a bad habit of using it to store information that should be have been delineated as part of its own class file though. Like for game logic values.