From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Edit Box Control Backcolor Briefly

Solved!
Go to solution

Hi,

 

I have an apparently simple problem that I cannot solve in the dialog box editor. I have a button and an editbox control on a dialog box and all that is required is that when the button is pressed some text should appear in the editbox and the editbox backcolor should change briefly to another colour before then reverting back. On the basis that the lines of code that change the backcolor will be executed very quickly I have tried to use Pause() just to hold the backcolor for a moment before changing back. However, what seems to happen is the pause is executed before the colour change, so no colour changes are seen. The code is:

 

Sub Btn_SPAD_EventClick(ByRef This) 'Created Event Handler
  EditBox1.Text = "SPAD"
  EditBox1.BackColor = RGB(95,153,240)
  Pause(1)
  EditBox1.BackColor = -1
End Sub

 

I have tried various insertions to refresh the textbox or the dialog itself but to no avail. I have also put the Pause in other Subs, like the editbox change or refresh events but also to no avail.

 

How do I get the backcolor to change briefly before reverting back?

 

Thanks.

 

0 Kudos
Message 1 of 3
(866 Views)

Hi Simon_Aldworth,

 

Please try the attached SUD.

 

Greetings

Walter

0 Kudos
Message 2 of 3
(837 Views)
Solution
Accepted by topic author Simon_Aldworth

Thanks Walter. As it happens I managed to find a solution, but I avoided using Pause as that seemed to be causing the problem for me. I found that whenever I used Pause it would interfere with other lines in the same sub, that is to say, the lines didn't seem to execute in order. I used the following in the end:

 

Sub Btn_StrEquip_EventClick(ByRef This) 'Created Event Handler
  Test = "Steering Equipment"
  SetTest(Test)
End Sub

Sub SetTest(Test)
  Text1.Text = Test
  Text1.BackColor = RGB(95,153,240)
  Dialog.RefreshAll
  xStart = Timer
  Do Until Timer > xStart + 0.3
  Loop
  Text1.BackColor = -1
End Sub

 

The separate function is irrelevant. I have many buttons on the form all doing similar things so I separated out the function to change the text and backcolour.

 

Regards.

Message 3 of 3
(821 Views)