Binding an Enhanced List at runtime


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 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

Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K 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.

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