Global Variable to a form


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
At this point, if I understand you correctly, you should be handling the BrowseDialogClosed event on the BrowseDialog control itself...or one of the other events on the BrowseDialog control.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Thanks. Just one other issue here. The CstomerMaintenance form does trigger the OnActivated when shown but if I clicked on BROWSE, then select a record from the browsedialog, when the CustomerMaintenance form displays, the OnActivated method is not trigered. What even is triggered?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You can place a shared property anywhere.  In this case you could put it on your form or browse...it depends when and how you plan on using it.  This is really more of a judgement call on your part.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Where would I insert the class MyClass so that I could refer to "MyClass.MyValue = true;" in the the CustomerMaintenance form AND the CustomerBrowseInfo panel? Would it be in the "AppMain.cs" or the "SecurityMain.cs"? 

public class MyClass

{

private static bool _MyValue = false;

public static bool MyValue

{

get

{

return _MyValue;

}

set

{

_MyValue = value;

}

}

}


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
It sounds like you might be making things more complicated than they may need to be...and emulating keystrokes is generally not a good idea (though I admit that I have done this before).  When using SendKeys API you can encounter different behavior on different systems and environments, so it is generally better to inherit and/or trap events or take an approach that will breed consistent results.  At any rate, let me address your questions:

What method always gets executed when the for is shown? The OnShown only seems to occur the 1st time the CusomerMaintence for is shown.

Yes, the OnShown will only be raised once when the form is shown.  You may be more interested in looking into something like the OnActivated event...I really don't know exactly what you are trying to do, but the OnActivated will be raised each time the form is activated.  You can also look through the MSDN documentation or the object browser to see all of the form events and how those events react.

[quote]How do I set up a public Boolean variable such as "addMode" that can be set to true if the user clicks NEW on the BrowseInforPanel that can be accesses from the CustomerMaintenance method the is always triggered when the CustomerMaintenance form is displayed.[/quote]

You don't want to create a public variable but a shared property.  This is the same basic concept but a much safer and cleaner way to approach a shared (or global) type of value:

Public Class MyClass

    Private Shared _MyValue As Boolean = False
    Public Shared Property MyValue() As Boolean
        Get
            Return _MyValue
        End Get
        Set (Byval value As Boolean)
             _MyValue = value
        ENd Set

    End Property
End Class

You could then access that property from anywhere.  In the above case, you would access it like this:

MyClass.MyValue = True

Notice that I do not first need to create an instance...this is important because it is a shared property and will not support more than one instance, thus it will be automatically instantiated and then accessible from anywhere that has access to the definition of the class/property.

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)StrataFrame User (195 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Using your SecuritySample in C#. I made a change to have the browse form appear first. The user can search first. If they do not see the customer they want, I added a "NEW" button to a "BrowseInfoPanel" That appears. Currently when the user clicks on the NEW button the logic does a SENDKEYS to actual execute the CANCEL button to make the BROWSE form go away and bring up the CustomerMaintenance form. Certainly at this point the user could click on the NEW button, but I want the NEW button already clicked if the NEW button was already clicked from the BrownInfoPanel. I already know that when the CustomerMaintenance form appears all I need to do is execute the ADD() to activate the ADD mode and a SENDKEYS with a TAB to place the focus on the first field. My 2 questions here are as follows:

1. What method always gets executed when the for is shown? The OnShown only seems to occur the 1st time the CusomerMaintence for is shown.

2. How do I set up a public Boolean variable such as "addMode" that can be set to true if the user clicks NEW on the BrowseInforPanel that can be accesses from the CustomerMaintenance method the is always triggered when the CustomerMaintenance form is displayed.

Hoping not to have to roll my own browse or maintenance for in that I am using the framework to save time. Could you provide some sample code rathyer than provide conceptual theory?

I have searched the complete formum and documentation already for a solution. This is why I am asking you at this point. 

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