Results 1 to 12 of 12

Thread: [RESOLVED] SetFocus on form created in RunTime

Threaded View

  1. #10
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: SetFocus on form created in RunTime

    Using API and determining the form's internal ID number is way overkill. Just make up your own unique identifier for the forms, (like, say, the treeview node's .Key property) and stuff that into the forms' .Tag property.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim frm As Form
    
        If Not Treeview1.SelectedItem Is Nothing Then
            Set frm = New Form2
            frm.Tag = Treeview1.SelectedItem.Key
            frm.Show
            Set frm = Nothing
        End If
    End Sub
    
    Private Sub Command2_Click()
        Dim frm As Form
        
        For Each frm In Forms
            If frm.Tag = [some value] Then frm.Show
        Next
        Set frm = Nothing
    End Sub
    Last edited by Ellis Dee; May 31st, 2007 at 02:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width