I'm having a panel inside another panel. Now I need to alter inner panel's visibility based on certain condition. But I'm unable to change. It always remains to False. Here is the code I'm trying to:
PnlTagFolders.Visible = True 'Always remains False.
PnlTagFolders.BringToFront()
Here is the screenshot for reference:
You can't make a Panel visible if the parent Panel isn't visible. So make sure the parent Panel is visible (.Visible = True).
true if the control and all its child controls are displayed; otherwise, false. The default is true.
source: Microsoft Docs
See the following:
ChildPanel.Visible = False
ParentPanel.Visible = False
ChildPanel.Visible = True
Debug.Print(ChildPanel.Visible) 'False
Another example:
ChildPanel.Visible = False
ParentPanel.Visible = True
ChildPanel.Visible = True
Debug.Print(ChildPanel.Visible) 'True
The script is intended to break the loop on XButton1, but fails.
I am a newbie in AHK scripting and a really simple script I made is not working as intended. I googled it and it works on everyone.
ended = false
XButton1::
ended = true
return
$XButton2::
ended = false
Loop
{
if (ended = true)
{
break
}
MouseClick left
Sleep 10
}
return
It was supposed to click infinitely until Mouse4 (XButton1) is pressed. But it does not stop when I click it.
I also checked other StackOverflow posts and nothing solved it.
Your code uses legacy-syntax which was a major headache for me (and I believe many others) when I was starting with AHK.
To make your code work change:
if (ended = true)
to
if (ended = "true")
Consider switching to := (SetExpression) instead of =
For example:
ended = false
should become
ended := false
I am trying to achieve wrapping and unwrapping of text in C1FlexGrid columns in a menu click event handler. The below code works to wrap the text when appropriate menu action is selected. But how I can unwrap the text?
Me.Styles(C1.Win.C1FlexGrid.CellStyleEnum.Normal).WordWrap = True
Me.AllowResizing = AllowResizingEnum.Rows
Me.AutoSizeRows()
I tried the below code but it did not make any difference. Any help is appreciated. Thank you!
Me.Styles(C1.Win.C1FlexGrid.CellStyleEnum.Normal).WordWrap = False
Me.AllowResizing = AllowResizingEnum.None
Me.AutoResize = False
I have a fillable PDF file. I would like to require that a TextBox has a value when the user saves the PDF document i.e. the value is not blank.
Here is what I tried:
(1) Setting the "Required" field on the "TextBox".
PROBLEM: That didn't do much except color the textbox red.
(2) I tried to use the following code in the "onBlur" event:
f = getField(event.target.name)
if (f.value.length == 0)
{
f.setFocus()
//Optional Message - Comment out the next line to remove
app.alert("This field is required. Please enter a value.")
}
PROBLEM: If the user never clicks this box there is no problem
(3) I tried to use the "Validation" tab and run a custom JavaScript.
PROBLEM: If you don't click on the box there is no validation so it is perfectly happy to leave the textbox blank if the user forgets to fill it in
OK, I am out of ideas... Anyone?
Since you are using Acrobat JavaScript I assume you use a viewer that supports and executes Acrobat JavaScript. In this situation you can set the document's WillSave action to a custom JavaScript action and perform validation here. I'm not sure if you can cancel the save operation but at least you can display an alert if the validation fails.
UPDATE: This script will loop through all the fields and display and alert if the field value is empty.
for ( var i = 0; i < this.numFields; i++) {
var fieldName = this.getNthFieldName(i);
var field = this.getField(fieldName);
if (field.value.length == 0)
{
field.setFocus()
app.alert("Field " + fieldName + " is required. Please enter a value.")
}
}
Put the script in document's Will Save action and it will run every time the user saves the form. In Acrobat you set this in Tools > JavaScript > Set Document Actions and select Document Will Save.
this is more of an advise thread I guess.
I've been wondering how one could create a button which display "play" when it's not pressed. And then shows "pause" once it's pressed. And visa versa when it's pressed again.
I had a similar problem when trying to create an expand panel button, but that was easy because I could just set a variable to true or false if PanelCollapsed was true.
But in this case I couldn't find any property in a button that I could query.
So I came up with this but I can't help thinking that this is a rather unsmart way of doing it?
If isPlay = True Then
If isPaused = False Then
btnPlay.Image = Image.FromFile("iconPause.png")
isPaused = True
isPlay = False
End If
GoTo Endline
End If
If isPlay = False Then
If isPaused = True Then
btnPlay.Image = Image.FromFile("iconPlay.png")
isPaused = False
isPlay = True
End If
End If
Endline:
How about using only one variable and code like this:
If isPlay Then
btnPlay.Image = Image.FromFile("iconPause.png")
else
btnPlay.Image = Image.FromFile("iconPlay.png")
End If
isPlay = not isPlay
You can use the "Tag" property. Its type is "object" so you can use any object you want, but in your case a string will do:
If Button1.Tag = "Pause" Then
Button1.Image = Image.FromFile("iconPlay.png")
Button1.Tag = "Play"
Else
Button1.Image = Image.FromFile("iconPause.png")
Button1.Tag = "Pause"
End If
Most .NET WinForm controls have a 'Tag' property (a button has one). You can set the Tag to be anything you want. An easy way to do this is to set the 'Tag' property to a boolean with the state of the button.
Just an idea...sure there are many other approaches.
UPDATE:
Otherwise, you can maintain the state of the button in your application as its own member variable. This might have several advantages because you can pass this state to other controls that might need it. The only weakness with this approach is that the state must be maintained separately.
If you have a fairly straight-forward implementation, use the Tag property.
A contrary opinion ...
... while other answers have given you some techniques to achieve your desired result, I'm going to ask you to reconsider your UI design.
Dual state buttons - ones that alternate purpose when clicked - can be a source of user frustation.
Here are two scenarios.
Scenario #1 ... if the users machine is under load (for any reason), there may be a perceptible delay between the users actual click on your button and when your click handler is executed.
Normally the time between click and handler is a few milliseconds or less, but it can run to several seconds. If this happens when the user clicks on a dual state button, they are likely to click the button again. Net effect, when the application catches up, is to toggle on, then immediately off again.
Scenario #2 ... many users habitually double click everything. Even experienced users who've been using computers for years may have this weird habit. When they try to press a dual state button, guess what happens ... the action toggles on, then immediately off again.
There are at least two solutions ...
Solution #1 ... use two buttons, one for "On", one for "Off".
Solution #2 ... write some debouncing code to suppress the effect of a second click if processed immediately (ie: < 75ms) after the first.
I don't personally use Visual Basic, but I do know that Buttons in Windows Forms have a property called 'Tag'. It is of the generic object type, so you can save whatever state you want, and just use casting to get the value back out.
How about using the "Image" property?
Rem form initialization
ImagePlay = Image.FromFile("iconPlay.png")
ImagePause = Image.FromFile("iconPause.png")
Button1.Image = ImagePlay
.
.
.
Rem on button1 click
If Button1.Image = ImagePlay Then
Button1.Image = ImagePause
Else
Button1.Image = ImagePlay
End If