MdiWindowListItem


Author
Message
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

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
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

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
Hi Teddy.

I'm glad Trent could help you, he got all this from me... oh, wait, I think the orther of the words are not set properly...

Unsure

Teddy Jensen
Teddy Jensen
StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 8K
Hi Trent,

Thanks - i got it now. My problem was that i set the text of an employee form to the name of the employee after it is loaded from a browsedialog. So i wanted the new text of the form to be renamed/refreshed in the list.

The rest was just cosmetic customations of the properties.

/Teddy

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Really all you need to do is set the MdiParent property on the parent form to False.  Drop a FlowLayoutPanel (or ThemedPanel) on the form and dock it left.  Next, in your main form, define an MdiClient class (it is a control) as a private and manually add it to the form.  This MdiClient will be where all of there client forms will appear, but the panels docking will be left intact.

Private _MdiClient As New MdiClient()


Public Sub New()
    _MdiClient.BackColor = Color.White
    Me.Controls.Add(_MdiClient)
End Sub


Teddy Jensen
Teddy Jensen
StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)StrataFrame User (152 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 8K
Ivan,

Your main form looks really good. I too was first thinking of a toolstrip dropdown that would show the open windows.  Now i have decided to use a panel like yours and the one from Practice Studio, so i can use it to show some more info. I do however have issues with this (read - it doesn't look the way i want it)

Can you describe how you did your panel and lists?

TIA.

/Teddy

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Well, basically this is just a docked Panel on the main form which we custom render and then add the logic we need for MDI Window Activation.  One thing that you can do is create an MDIClient class and then add that class as a control to the main form rather than setting the MdiContainer property....it just gives you more flexibility.

This entire explanation would be more of a tutorial rather than a quick post here...and in fact, this is one of the very things that we cover during class.  I know you guys haven't had a chance to make it to class in the past, but if it were at all possible, I think that you guys would gain a lot of first hand experience on items just like this if you were able to make it to the next class Smile 

StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Hi guys,

A couple of questions.... I am using a picture that you used earlier in the post... how did you create that MDI with that control panel on the left?

am i correct in assuming that if the user were to click or double click on the name of a form in the list in the control panel it would show that form?

and second, using the code you provided earlier in this post... how would I create navigation buttons to utilize this code... lets say that I wanted navigation buttons in the MDI to be able to navigate through all the child forms... yknow the basics... first, previous, next, last.

This is a really cool concept! I'm eager to implement it. BigGrin

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Glad it worked for you Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search