View previous topic :: View next topic |
Author |
Message |
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Tue Dec 02, 2008 1:29 pm Post subject: Focus lost after closing universal editor form |
|
|
We are using a virtual tree in an Interop Usercontrol, so that this control can be used on a VB6-form. The virtual tree looks like the Custom Type Editor sample. Values in the tree can be changed by pressing the little button in the edit field, and then a form is opened to select a new value, like what happens in the StockLevelEditor:
Code: | Public Overloads Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object
Dim editorService As IWindowsFormsEditorService
editorService = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
' create and initialize our form
'
Dim form As New StockLevelForm
form.Part = context.Instance
form.StockLevel = value
' use the editor service to display the form
'
editorService.ShowDialog(form)
If form.DialogResult = DialogResult.OK Then
Return form.StockLevel
End If
Return value
End Function 'EditValue |
However, when the user presses OK in the form, the new value is inserted in a field in the tree, but this field is not active. So when I press ENTER, nothing happens.
Is there a way to make this edit field (from where the form is opened) active again at the moment that the form is closed?
Thanks,
Anja |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Dec 02, 2008 10:19 pm Post subject: |
|
|
This isn't the behaviour you get with the Custom Type Editor sample. When you click OK on the editor form the UniversalEditBox control still is active. Are you saying that the behaviour for your control is different? If you use your control inside a standard windows form (instead of via COM interop) does it work the same? _________________ Infralution Support |
|
Back to top |
|
|
AB
Joined: 20 Nov 2007 Posts: 23 Location: Netherlands
|
Posted: Wed Dec 03, 2008 3:21 pm Post subject: |
|
|
Yes, the behaviour for my control is different.
The Custom Type Editor sample works fine.
When I test my control in the VB.NET UserControl Testcontainer (by pressing F5) there are no problems, but when I use this control in a VB6 project, it seems that after opening and closing a form which is made in VB.NET, the focus is lost.
I solved this by setting
Code: | MyTree._VirtualTree.EditWidget.EditorControl.Focus() |
after the form is closed in the EditValue function. |
|
Back to top |
|
|
|