Hello,
I've been searching the form for a solution to my problem but I haven't found it. Maybe there is no solution.
I've got a user form with some image lists on it, based on groupmembership.
If a user is not a member of the group a grayed out image is shown on the button. When you click the button, a popup is shown to add the user to the group, after that the popup is closed and you return to the main form.
Is it possible to "refresh" the button with a new image? So the groupmembership needs to be checked again.
Thanks
Sander
Another refresh question
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Another refresh question
In my test I've mannaged to change the image on the button. (by making a second button with the change action).
Is it possible to change the image on the mainform by clicking a button on the childform?
How do I call the $buttonRemoteToegang.image on the mainform?
Thanks!
Sander
- $buttonRemoteToegang.Image = $imagelistDnstRemoteToegang.Images[0]
How do I call the $buttonRemoteToegang.image on the mainform?
Thanks!
Sander
Re: Another refresh question
You can change the image on a button at any time by just setting the "image" property to a different image. No need for a new button.
You can change a parent form by address the parent property of the child form. Changes will not be visible until the event exits.
$childform.Parent.Controls['mycontrol'].Image = $newimage
You can change a parent form by address the parent property of the child form. Changes will not be visible until the event exits.
$childform.Parent.Controls['mycontrol'].Image = $newimage
Re: Another refresh question
I don't get it, would you be so kind to have al look at my test project?
So after you click the enable button on the childform it should change the image on the button of the mainform.
Thanks!
So after you click the enable button on the childform it should change the image on the button of the mainform.
Thanks!
- Attachments
-
- ImageList.zip
- (63.83 KiB) Downloaded 128 times
Re: Another refresh question
What you are trying to do won't work. This is not how Windows forms is designed to work. With Sapien forms the variables are in a different scope and unavailable.
Your design is also suspect. Why would you think you need to do this? A modal dialog is intended as an independent and isolated object. It should operate on data. Show_ChildForm returns a dialog result. The result can be used to change the state of the calling form. Data from the calling form can be passed in a "Param" statement.
Your design is also suspect. Why would you think you need to do this? A modal dialog is intended as an independent and isolated object. It should operate on data. Show_ChildForm returns a dialog result. The result can be used to change the state of the calling form. Data from the calling form can be passed in a "Param" statement.
Re: Another refresh question
The following will switch images:
- # make mainform work like this
- $formMainForm_Load={
- }
- $buttonOpenPopup_Click={
- Show-ChildForm_psf ([ref]$buttonOpenPopup)
- }
- #make childfrom work like this
- param(
- [ref]$buttonOpenPopup
- )
- $formChildForm_Load={
- }
- $buttonEnable_Click={
- $buttonOpenPopup.Value.ImageIndex = 1
- $formChildForm.Close()
- }
Re: Another refresh question
I should also note that, in the case of this control, the image is updated immediately. Some operations may not happen immediately but images bound to an ImageList will update when changed by a child.
Re: Another refresh question
This is just a test. In my real project I have a button with an image on it. When a user is a member of the group "Remote Access" the image is "on" if the searched user is not a member (the image is gray) the admin can click the button and a popup is shown where the admin can click a button to add the user to the group, after that the popup is closed.
But when you return to the mainform the image is still gray, the admin has to close and reopen the form to get the right image.
That's why I wanted this option, so that the admin could see that the change was made.
The last solution works for me, thanks for you help! Again
But when you return to the mainform the image is still gray, the admin has to close and reopen the form to get the right image.
That's why I wanted this option, so that the admin could see that the change was made.
The last solution works for me, thanks for you help! Again
Re: Another refresh question
In you case the child form can access the variables of the calling function.
This will wok in the child:
Since the child function I s called in the scope of the parent form then all objects that are defined can be changed. This would not be true of "ValueType" variables which must be passed as "[ref}" types.
Part of your issue is likely because you are using an ImageList and, once bound, changing the image is only possible via the image index or ImageKey.
This will wok in the child:
Code: Select all
$buttonEnable_Click={
$buttonOpenPopup.ImageIndex = 1
$formChildForm.Close()
}
Part of your issue is likely because you are using an ImageList and, once bound, changing the image is only possible via the image index or ImageKey.