Help understanding BrowseDialog inheritance


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I have a base BrowseDialog I want to use in other similar forms that share the same search table but with different fields. Ok I created my base class BDBase and setup all possible search fields in SearchFields property and also setup the BrowseResultsLayout.



So far so good. Now I create another class and inherited from BDBase and in the designer, I removed the fields I don't need from SearchFields and BrowseResultsLayout. When I add an instance of this class in my form, those 2 properties are reset to the default values in BDBase class.



What am I doing wrong? Also is this the correct approach to reuse the BrowseDialog?

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



Just in case this message was overlook, please see if you can help me out here.



Thanks!

Edhy Rijo

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
First, let me understand. You are wanting to create a base browse dialog that all of your other browse dialogs, correct? Or, are you just wanting to class your existing BD so that you can reuse them over and over again.



In teh case of the first, which I think you are getting at, there are times when you will have to override the property (or you are setting a property) in the Load or constructor of the class. If this is a property and you are overwriting base logic, then you may need to create an internal private, override the property, and implement your logic.



What properties specifically are you getting at here?
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well basically I have several forms which use the same Parent Table, I want to have a single BrowseDialog class to be reused by each form, but the key here is that each form will use different SearchFields from the same Parent Table.



So in this case for each form some SearchFields will always be reused and some will be unique, as well as the BrowseResultsLayout which will have some common fields and some unique.



Due to the similarities, I though of using a single BrowseDialog base class (like in the StrataFlix sample) but when I drop an instance of my BD class in each form and manually adjust the SearchFields and BrowseResultsLayout properties, when I run the form those properties revert back to their original value in the base class.




Edhy Rijo

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
Yeah, in this case you may have to override these properties and then re-expose the underlying property. In fact, you may want to create your own search fields and browse results property on the base class and then after the load, you will set the SF properties. This will allow the base class to initialize then in essense you will be clearing out and resetting the base properties.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (08/04/2009)
In fact, you may want to create your own search fields and browse results property on the base class and then after the load, you will set the SF properties.




In the base BD class I have all fields I will use in all forms, then in my form in the BD.InitializeSearchFields() I have some code to set SearchFields("PONumber").Visible = False, and in fact this will now show that field, but will leave the dialog with an empty space in the groupbox of the search fields, so the group box will not resize automatically. Is there a way to overcome this, other than have a BD for each form?




Edhy Rijo

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
Is there a way to overcome this, other than have a BD for each form?




Yes. I never have a single BD per form and create classes for all my BD. Maybe a sample showing the issue you are fighting would help so I can see what you are doing.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



I am setting up a simple sample that will show this scenario, please stay tune!!! Tongue

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



Attached please find the requested Sample. It is a very easy sample and follows the StrataFlix sample for the BDs.





In the BrowseDialogClassSample.UI project I created a BaseBrowseDialog.vb class and setup the SearchFields and BrowseResultsLayout properties to use all possible fields I will use in the next 2 inherited classes:



- BrowseDialogForNamesOnly.vb: This class should show the following fields:

- SearchFields: cust_Company, cust_FirstName, cust_LastName



- BrowseResultsLayout: cust_Company, cust_FirstName, cust_LastName



- BrowseDialogForPhonesOnly.vb

- SearchFields: cust_PhoneDay, cust_PhoneNight



- BrowseResultsLayout: cust_FirstName, cust_LastName, cust_PhoneDay, cust_PhoneNight



The whole idea is to have a base class BD and then use it in several form with different searchfields and BrowseResultLayout columns.



I hope you can make the changes to this sample and re-post it so we can see how this should be accomplish.



Thanks!


Edhy Rijo

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
Ok, you can take several routes on this, but here is my suggestion and the easiest route. Since you are in control of the dialogs and know what you need, you can override the OnInitializeSearchFields method, for example, and dynamically build your search list. So using the sample that you gave, if I only wanted the company field as a search field in the BrowseDialogFormnamesOnly class, then I would do this:



Protected Overrides Sub OnInitializeSearchFields(ByVal e As System.EventArgs)

Me.SearchFields.Clear()



'-- Build the desired search fields list

Dim item As New MicroFour.StrataFrame.UI.Windows.Forms.SearchFieldItem()

item.FieldName = "cust_Company"

item.AllowAdvanced = True

item.DefaultSearchStyle = MicroFour.StrataFrame.UI.BrowseDialogAllSearchTypes.BeginsWith

item.FieldLabelText = "Company:"

item.FieldName = "cust_Company"

item.FieldType = Data.DbType.AnsiString

item.InitiallyEnabled = True

item.Key = "cust_Company"

item.Visible = True



Me.SearchFields.Add(item)



MyBase.OnInitializeSearchFields(e)

End Sub




Obviously you can clean this up and add a method to generate this list, etc. But this is a quick and dirty way to get this working the way that you like. You can take a similar approach for the browse results layout.
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