MdiWindowListItem


Author
Message
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hiya.

I am shamelessly trying to copy "someone's" idea of a MainForm.Tongue

My intention is to get rid of the MenuStrip and use the ThemedToolStrip instead. So far, so good. But now I got to the "Window" item, which will show the opened MDI windows list.

Now I would need to have a "Window" ToolStripDropDownButton to behave in the same way as the MenuStrip MdiWindowListItem. Would that be too difficult to implement?

Cheers.

Replies
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
H all,

I am using the LoadForm method posted here to load the forms, but I would like to automate this method by passing the form name stored in a Tag property of a menu item or a DevExpress RibbonControl Item.

The item will have the name of the form as string like this "frmProducers" but the LoadForm method is expecting a System.Type parameter instead of string, how can I either convert the Item.Tag string containing the form name as a System.Type expected by the LoadForm method posted here?

Private Sub LoadForm(ByVal FormType As System.Type)

'-- Establish Locals

Dim loForm As System.Windows.Forms.Form

'-- Create the form

loForm = CType(Activator.CreateInstance(FormType), System.Windows.Forms.Form)

'-- Associate the new form with the MDI form

loForm.MdiParent = Me

'-- Add a handler to the form close

AddHandler loForm.FormClosed, AddressOf HandleFormClosed

'-- This is a good place to update your open form collection

_Forms.Add(loForm.Handle.ToInt32(), loForm)

'-- Update the list or menu

'-- Show the Form

loForm.Show()

End Sub

The whole idea is to either type the form name in the Item.Tag property or read it from a database to load all the Items and update the Item.Tag which will make a generic single call to the LoadForm.

Thanks.

Edhy Rijo

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can use System.Type.GetType(typeNameAsString) to convert a string to a System.Type.  You'll need to store more than just "frmFormName" in the tag of the form, however, because the Type.GetType() static method requires the full name of the class.

Type.GetType("MyNamespace.frmMyFormName")

That will be what you'll have to give it.

Also, it might be the case that that method will not be able to resolve the name because your form type exists in another assembly.  If that's the case, then you'll need to give it the fully qualified assembly name.  It's basically the full name with a comma and the assembly name right after it like this:

"MyNamespace.frmMyFormName, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

That's the difference between the Type.GetType() static method and the GetType() keyword (the keyword turns blue when you type it).  If you use the keyword, it will always resolve because the reference is resolved and at compile-time.  So, you might want to create a method that will resolve the names for you and uses the keyword to get the type.  Like this:

Public Shared Function ResolveFormType(ByVal formName As String) As Type
    Select Case formName
        Case "frmForm1"
            Return GetType(frmForm1)

        Case "frmForm2"
            Return GetType(frmForm2)

        Case "frmForm3"
            Return GetType(frmForm3)

    End Case
End Function

If you use this method, then the string can be any arbitrary value, as long as it's unique and you can assign it a type to return from the method.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ben Chase (03/31/2008)
You'll need to store more than just "frmFormName" in the tag of the form, however, because the Type.GetType() static method requires the full name of the class.

Type.GetType("MyNamespace.frmMyFormName")

Hi Ben,

Thanks for the explanation.  Using

Type.GetType("MyNamespace.frmMyFormName")
does give me the results I was looking for.

If I were to use the ReolveForm solution, I would then have to make an entry in the Case statement for every form I add to the project and all I am trying to do is to have all forms identified in a Item.Tag so I don't have to manually remember to keep adding it to the Case statement.  Thanks again!!!

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ivan George Borges - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ivan George Borges - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ivan George Borges - 19 Years Ago
                         [quote]You have put the Themed Containers in a docked form on the...
Trent L. Taylor - 19 Years Ago
                             Hey Trent, Nice, I have been attempting to do the same. Would be nice...
Michael Reese - 19 Years Ago
                                 Can't believe it, Trent ... I did it!!! It is even activating the...
Ivan George Borges - 19 Years Ago
                                     This form looks very familiar ... I just can't understand what it says...
Trent L. Taylor - 19 Years Ago
                                         Seriously...it looks great!
Trent L. Taylor - 19 Years Ago
Chan - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Michael Cobb - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Keith Gordijn - 17 Years Ago
Keith Gordijn - 17 Years Ago
                         That will work fine :)
Trent L. Taylor - 17 Years Ago
Michael Cobb - 18 Years Ago
             Glad it worked for you :)
Trent L. Taylor - 18 Years Ago
StarkMike - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Teddy Jensen - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Teddy Jensen - 18 Years Ago
Ivan George Borges - 18 Years Ago
Edhy Rijo - 17 Years Ago
StrataFrame Team - 17 Years Ago
                         [quote][b]Ben Chase (03/31/2008)[/b][hr]You'll need to store more than...
Edhy Rijo - 17 Years Ago
Chan - 17 Years Ago
Mike Tomlin - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Oh....nevermind, you are using that older logic on the window handles...
Trent L. Taylor - 17 Years Ago
                             Since we no longer use this logic I hadn't noticed that Vista changes...
Trent L. Taylor - 17 Years Ago
                                 [quote][b]Trent L. Taylor (04/15/2008)[/b][hr] [codesnippet]For each f...
Edhy Rijo - 17 Years Ago
                                     You would be passing it into some method. If you look further up the...
Trent L. Taylor - 17 Years Ago
Teddy Jensen - 17 Years Ago
Edhy Rijo - 17 Years Ago
Paul Chase - 17 Years Ago
lastcanary - 15 Years Ago
Ivan George Borges - 15 Years Ago
Russell Scott Brown - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search