Security Sample question.


Author
Message
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)StrataFrame User (245 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Your SecuritySample (C#) displays the main form for the app (SecurityMain) which has a flow panel to the left (pnlSide)with a themed container (ThemedContainer1). I like this approach but have a question. I want to expand on this some that when the Customers button the the SecurityMain form is clicked and the CustomerMaintenance form appears, it would dynamically add another ThemedContainer2 to the SecurityMain form's pnlSide area.

First I added a user control called CustomerMaintenanceThemedContainer which inherited from the Strataframe Themed Container. and used the Visual Designer to get it the same with, look and feel as the one already on the SecurityMain form.

My thought is to add a ThemedContainer to the pnlSide area of the SecurityMain form whenever I display another form such as the CustomerMaintenance form to give the user other information or links they could click on for the form.

When the CustomerMaintenance form first displays, what code would I need to add the Themed Container to the pnlSide area of the SecurityMain form? And then when the user CLOSES the CustomerMaintenance form, what code would be needed to removed the Themed Container from the pnlSide area on the SecurityMain form?

I added the following code on the button click of the cmdCustomers button on the SecurityMain form which does work, but this should happen as a part of the CustomerMaintenance form and not the button click on the SecurityMain form. Valet is my namespace for my application. My question is how do I get a reference to the SecurityMain form once the CustomerMaintenance form is displayed so that I can control the displaying of the associated Themed Container and removing it from the CustomerMaintenance form?

Valet.frmCustomerMaintenanceUserThemedContainer ThemedContainer2 = new frmCustomerMaintenanceUserThemedContainer();

this.pnlSide.Controls.Add(ThemedContainer2);

LaunchForm(typeof(frmCustomersMaintenance));


Reply
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
OK...a couple of things.  You don't want to re-write this code over and over again so this logic should be placed in your BaseForm.  All of your maintenance forms will inherit your BaseForm which inherits from our StandardForm:

Public Class MyBaseForm
    Inherits MicroFour.StrataFrame.UI.Windows.Forms.StandardForm
End Class

Next, you will probably just always allow that themed container to be on the side panel, just change its visibility and place it as well as any other items in a FlowLayoutPanel.  This way when you change their sizes and visibilities the other controls will automatically adjust themselves in respect to the controls being changed.

Finally you will need to create a shared reference to that object and/or create a shared event that is managed by application.  You can go a lot of different ways on the event in regards to who manages what.  For example, you could create a shared event that the ThemedContainerClass that will be in the panel manages.  Conversly you could create an event that is managed by the form which forces the logic to execute.  If you just want to go down the object route, then create a shared reference to the themed continer and then in your base form add your logic:

Public NotInheritable Class MyBasics
    Private _PanelContainer As ThemedContainer

    Public Property SidePanelContainer as ThemedContainer
        Get
              Return _PanelContainer
        End Get
        Set(Byval value as ThemedContainer)
              _PanelContainer = value
        End Set
    End Property
End Class

Set this property in your application once the object has been created.  It could be in the panel itself it necessary:

MyBasics.SidePanelContainer = Me

Finally, add your logic in your base form to update the container:

Overrides Protected Sub OnLoad(...)
    MyBase.OnLoad(...)
    MyBasics.SidePanelContainer.Visible = True
End Sub

Overrides Protected Sub OnFormClosing(...)
    '-- Add your logic to see if the container should be removed
    MyBasics.SidePanelContainer.Visible = False

   MyBase.OnFormClosing(...)
End Sub


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