StrataFrame Forum

maintenance toolstrip browse button and ShowDialog(true)

http://forum.strataframe.net/Topic10955.aspx

By Marcel Heitlager - 8/20/2007

I like to have the result prefilled.  When I call showdialog(true) in the ItemClicked event I naturally get a 2nd instance of the BrowseDialog. How do I override the default PopulateOnShow Property?

Also (side question), has anyone tried to paginate the browse dialog results, if there more results you care to show on one page?

Thanks,

Marcel

By Trent L. Taylor - 8/21/2007

First, when you are talking about the ItemClicked event are you referring to the MaintenanceFormToolstrip here.  If you call the ShowDialog(True) it will only bring up a single instance unless you call this through that button since two handlers get created and thus fired twice.  As for overwriting the PopulateOnShow property, subclass your BrowseDialog and then you can overwrite the property.

As for pagination, no.  There is really no way for you to do this within this dialog as we create a QueryInfo class that performs the query on the backend which is dynamically built and is non-database dependent.

By Marcel Heitlager - 8/21/2007

Thanks for the reply.

I don't see how I can override the PopulateOnShow property since it is set in the ShowDialog() method to False (and that's called from the toolbar(i think).

I tried to inherit from the BrowseDialogClass with the following code overriding showdialog (since it is overridable)

[codesnipper]

Namespace UI.Windows.Forms

<DefaultEvent("RowPopulating")> _

Public Class PrefilledBrowseDialog

Inherits MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog

''' <summary>

''' Override the ShowDialog function of browseDialog class

'''

''' </summary>

''' <remarks></remarks>

Public Overrides Function ShowDialog(ByVal PopulateOnShow As Boolean) As System.Windows.Forms.DialogResult 

'''-- above is line 19

Return MyBase.ShowDialog(True, Nothing)

End Function

End Class

End Namespace

[/codesnippet]

This keeps on throwing an exception though:

System.ArgumentOutOfRangeException was unhandled by user code
  Message="Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
  ParamName="index"
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.SetGroupBoxDimensions()
       at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow..ctor(BrowseDialog BrowseDialogSettings, Boolean PopulateOnShow)
       at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow, IWin32Window ResultsWindowOwner)
       at mhControlLibrary.UI.Windows.Forms.PrefilledBrowseDialog.ShowDialog(Boolean PopulateOnShow) in D:\_VS2005Projects\SHARED\mhControlLibrary\mhControlLibrary\PrefilledBrowseDialog.vb:line 19 +++++Which is overrides line above +++++
       at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog()
       at PPM_New.it.llblManagePlans_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) in D:\_VS2005Projects\DEV\PPM_New\PPM_New\forms\it.vb:line 77
       at System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e)
       at System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Label.WndProc(Message& m)
       at System.Windows.Forms.LinkLabel.WndProc(Message& msg)
       at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
       at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 

Crazy I'm probably missing something obvious here. Any thoughts?

Marcel

By Marcel Heitlager - 8/21/2007

OK I figured out that the error has to do with not having any businessobjecttype property values, etc.  It seems that everytime I fill those values in, in the overrided class, once it is compiled and runs, when I open the form again in the form designer, the values have all reset themselves to the initial values.

Any ideas on why that would happen?  I also notice that the values I enter, don't show as bold, except for the businessobjecttopopulate property.

By StrataFrame Team - 8/22/2007

The reason that those properties don't serialize themselves (write themselves to the .designer.* file) is that all of the properties have corresponding ShouldSerialize[PropertyName]() methods that tell the designer not to serialize them if the BrowseDialog is inherited (meaning it's a subclass like the one you've created).  The reason for this logic is as follows:

The BrowseDialog is designed to be inheritable so that you can, say, create a CustomersBrowseDialog and reuse it througout your application.  So, you create a class, inherit from BrowseDialog and through the component designer, set all of the properties on the custom BrowseDialog so that you only have to set them once.  However, whenever you drop the custom browse onto a form, all of those properties are re-serialized.  Meaning that all of the collections (SearchFields, ResultsLayout, etc.) get doubled-up.  It also means that if you go to the component designer and change a property, it is not propagated throughout your app to all of the instances of that custom browse (because the properties were serialized at whatever value they where when the custom browse was dropped on the form).  So, we fixed the BrowseDialog so that it will not serialize any of the property values of an inherited dialog.  This allows all of the properties within the component designer to be serialized, but when you drop it on a form, none of them are re-serialized (just the BusinessObjectToPopulate, since it it specific to the instance of the BrowseDialog). 

So, if you don't want this functionality, you can override the IsInheritedBrowseDialog() method of the business object.  When it returns true, the properties will not be serialized.  The base code checks to see if the current objects type is a subclass of BrowseDialog.  But, you generally want to leave the functionality and set the properties for the custom browse within the component designer of your custom browse so you don't have to set them on every instance of the browse dialog that you drop on a form.

By Marcel Heitlager - 8/22/2007

Thanks,

I was about to commit suicide.  But now it makes sense, and it works. I guess that's what newbies do. I appreciate your support.

Marcel

By StrataFrame Team - 8/23/2007

I was about to commit suicide.

When I get to that point in development, I just go play xbox until my nerves are a little less frazzled (or a least that's my excuse for playing as much Halo as I do Wink).