VB.NET Update User Control Immediately When UI Editor Changes - user-controls

I have a User Control in VB.NET (VS 2010) inherited from a picturebox. I also have a class that holds 40 or so properties for the control. I also have a form with a property grid that is used as an editor. The editor form opens when clicking the "Custom" property of the control in the IDE. On the form are an OK and Cancel button which either saves or discards changes.
All of this works fine, but I need to have my control "refresh" when a property changes in the grid. The property grid has an event for this, but I don't know how to call or invoke my sub in the control to essentially repaint the control. If I call the sub directly nothing refreshes on the control until after I close the editor form (dialog). Is there a way to have the control repaint/redraw with the editor dialog still open?
Thanks,
EluZioN

Try using Context.Instance which is passed when your UI_Editor is invoked. In the GetEditStyle override, a Context object is passed. This holds a reference to the calling UserControl.
I do something like this (CUSTOM UI_TYPE_EDITOR):
Dim ContextOBJ as MyUserControl
Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext)......
contextOBJ = CType(context.Instance, MyUserControl)
In the GetEditValue override, you can call ContextOBJ.Refresh and your UserControl should immediately reflect any changes. It works for me.

Related

Control Picker only shows controls on the Custom Control

I created a custom control with a custom property. The property type is String and the Editor is Control Picker.
When I place the CC on an xPage and try to set the property the editor displays just fine, the only issue is that it seems to only list the controls on the CC and none of the controls on the xPage.
Is anyone else seeing this issue?
There is another editor in the list called the 'XPage Control ID Picker' this editor will list all the controls in the higher level XPage that the custom control is on.

Saving the states of JavaFX controls on exit

I have a bunch of control objects (TextBoxes, to be precise) that get injected into my code using the #FXML annotation during the FXML load.
I would like to save the states of these controls, specifically the text values, when the user closes the Scene by clicking the close box on the title bar.
However, when I trap the CloseRequest event in an OnCloseRequest handler I find that the values of the control variables are null (the original injection works, so this is something that happens in between the loading of the FXML and the calling of OnCloseRequest).
Can anyone explain this behavior and/or suggest how I can get the functionality that I want?
TIA
onCloseRequest is
Called when there is an external request to close this Window. ...
(from Javadoc). One of the meanings of "external request" is when you close the window through OS native window close button. The closeRequest event is not triggered through the programmatic stage.close() or stage.hide() calls. So consider to handle onHiding or onHidden events.
Otherwise post your OnCloseRequest handler code.

LWUIT Dialog problem with dispose()

I am making a dialog with a command. This command must close the dialog and go back to the previous form, but it is not working as expected. When I press the command, it closes the dialog but the form do not go back.
I am using the resource editor. State machine controls the app´s navigation.
The code inside the command´s logic is:
dialog.dispose();
StateMachine.back();
Is dispose() the method that I must use to close my dialog?
Thanks for reading.
As Nirmal said disposing the dialog goes to the previous form so while your call to "back()" works as expected your call to dispose() breaks that logic.
You can override the postShow method for the form you are showing and detect the case of leaving the dialog (just turn on a flag when you need to go back) and call the back method when the form is shown in that condition.
dont call StateMachine.back() just use dialog.dispose();
There is another solution : try to use the protected void onShowCompleted() method that you must implement in your Form. And declare a boolean variable in your Form ( for example private boolean isDialogShown; ), then in the constructor of your Form set that boolean variable to false, and just before the code of opening the Dialog set its value to true. Then in the code of the protected void onShowCompleted() test if it is true , and if it is true then set it to false and perform the back action : backForm.showBack();

How can I get access to items of a modal dialog in MFC?

I just want to get access to an object in the modal dialog. The following example will explain exactly what I'm trying to do:
(This code is not working)
CAddDlg dlg;
CString S;
dlg.DoModal();
dlg.GetDlgItem(IDC_NAME)->GetWindowTextW(S);
MessageBox(S);
But an assert will fail and I can't get the text of the Edit control.
What should I do?
You can't access the controls of modal dialogs from outside. Even if you could, it's not a good idea. The caller of the dialog should not know how the data is represented in the dialog. What is now an edit control could be a listbox in the future.
The way to go is declare getter functions which you call after DoModal() (if it returned IDOK) and get the values there.
Check Can I return a custom value from a dialog box's DoModal function? for some examples

Validating/ed events not firing in class library windows form

I'm developing a Word 2010 add in using Visual Studio 2010, and C#.
I've created a simple form, with two textboxes, and an Ok button.
The Ok button's Causes validation property is set to true.
Both textboxes CausesValidation property is set to false, and their Validating and Validated properties are set. This is so that they are only validated when the Ok button is clicked, and not when focus is changed.
If the form code is defined within the Word add in, the validating and validated events run as expected - when the Ok button is clicked. I wanted to make the form reusable, so I moved the form into a separate class library. The form largely works as expected but the validating and validated events never run with the above configuration.
Does anybody know why this is the case? Is it a bug?
It seems that you can get things working if you:
1) Set the AutoValidate property of the base form to Disable.
2) Set the CausesValidation property on the textbox to true.
3) Call the this.ValidateChildren() method in the button click.

Resources