Binding an Enhanced List at runtime


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
How do you set up MethodToExecute if there is no parameter for the method being called?

Is that a trick question? Smile  You just leave off the parameters:

Me.grdHdr.PopulationDataSourceSettings.MethodToExecute = "FillDataTable;"

Geoff Hirst
Geoff Hirst
StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)StrataFrame User (219 reputation)
Group: Forum Members
Posts: 123, Visits: 3.5K
Guys,

How do you set up MethodToExecute if there is no parameter for the method being called?

thanks

Geoff Hirst

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
Yes, this is what we normally do as well.  Glad you got going. 
Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Ok, it looks like you have to populate a ListViewPopulationSettings object and then set it the listview property.  This now works for me:

PopSettings.BusinessObjectType = "BBS.Biz." & HdrValue & "BO"
PopSettings.DisplayFieldNames.Add(HdrValue)
PopSettings.FormatColumns.Add(
"{0}", MicroFour.StrataFrame.UI.ListViewColumnPopulationType.FormattedString)
PopSettings.FormatString =
"{0}"
PopSettings.MethodToExecute = "FillDataTable;System.String"
PopSettings.ValueMember = HdrValue
Me.grdHdr.PopulationDataSourceSettings = PopSettings


Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Oh, and my grid is actually the Enhanced List control from the DevX wrapper classes.  Forgot to say that I think.
Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Ok, I now have this:

Me.grdHdr.PopulationDataSourceSettings.BusinessObjectType = "BBS.Biz." & HdrValue & "BO"
Me.grdHdr.PopulationDataSourceSettings.DisplayFieldNames.AddRange(New String() {HdrValue})
Me.grdHdr.PopulationDataSourceSettings.FormatColumns.Add("{0}", MicroFour.StrataFrame.UI.ListViewColumnPopulationType.FormattedString)
Me.grdHdr.PopulationDataSourceSettings.FormatString = "{0}"
Me.grdHdr.PopulationDataSourceSettings.MethodToExecute = "FillDataTable;System.String"
Me.grdHdr.PopulationDataSourceSettings.ValueMember = HdrValue

But on the first line it gives me an exception and the message on Me.grdHdr is "Object cannot be null".  It looks like for some reason my grid is Nothing, but I created it on the form at design time so what else do I need to do to have an instance of it?


StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can set the properties of the EnhancedList at runtime, but you would probably be best served to create PopulationDataSourceSettings at design-time and then copying the code from the InitializeComponent method.  You're missing a few things when you're configuring them at runtime.

The MethodToExecute is a semi-colon-separated list of the method name and parameters... in this case, it would be "FillDataTable;System.String".  When we use the same list and populate it with several different data sets, we will set the PopulationDataSourceSettings manually within the code.  Other than that, your ListPopulating method is correct, but you'll need to call the Requery() method whenever you want to repopulate the list.

Andria Jensen
Andria Jensen
StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)StrataFrame User (406 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I'm trying to use a generic form to maintain several different tables in the database.  They all use the same form, but just different data sources.  What is the best way to do this in code at run-time instead of setting it through the designer at design time?  I figure I need to set some properties of the PopulationDataSourceSettings, but what I'm doing hasn't been working.  Here's the code I've got so far to bind the grid, and maybe someone can tell me what I have missing.

Public Class frmSFTableBase
   Public Sub New(ByVal HdrBO As BusinessLayer, ByVal HdrValue As String) 
      Me
.BusinessObjects.Add(HdrBO)
     
Me.grdHdr.PopulationDataSourceSettings.BusinessObjectType = "BBS.Biz.BizTypeBO"      Me.grdHdr.PopulationDataSourceSettings.ValueMember = HdrValue
     
Me.grdHdr.PopulationDataSourceSettings.MethodToExecute = "FillDataTable()"
     
Me.grdHdr.PopulationDataSourceSettings.DisplayFieldNames.Add(HdrValue)
      Me
.grdHdr.PopulationDataSourceSettings.FormatColumns.Add("{0}", MicroFour.StrataFrame.UI.ListViewColumnPopulationType.FormattedString)
      Me
.InitializeComponent()

End Sub

   Private Sub grdHdr_ListPopulating(ByVal e As   MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles grdHdr.ListPopulating

       e.Parameters(0).Value =
"SELECT * FROM BizType"
 
End Sub

End Class

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