Lookup Table Schema

Using DevForce to set up the Domain Model I wanted to get data into a ComboBox.
I wanted to come up with a pattern that I could use every time that I needed a ComboBox.
I will only want to show “Active” choices in the UI, also most times I want it displayed a specific way, thus the DisplayOrder field in the table.
I’m using DevForce 5.2.5 under VS2008 and SQL2008.
In the WinForm solution (this assumes that all the assembly references are set already) Drag a DevForce manager onto the Form and name it I have followed the DevForce naming conventions (I think). _objectCMB. Using the smart tag on the control select configure data bindings and select you binding object.
Now pull a Binding source control from the windows tool bar, name it _objectBS.
Now in the _objectCBM properties window set the BindingSource property to _objectBS.
[Note: This is a different order than the DevForce Docs state but when you do it that way after you come out of the configure databindings dialog the BindingSource gets removed, might be a bug]
Now drag a ComboBox onto the form. Set the DataSource to _objectBS then set the DisplayMember, ValueMember to desired properties. If you don’t see any that “should” be there make sure the BindingSource is set in the _objectCBM.
OK now the Code..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IdeaBlade.EntityModel;
using IdeaBlade.Util;
using DomainModel;
namespace WinFormSandbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load+=new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
ConfigureBindingSources();
ConfigureBindingManagers();
LoadSupportingData();
}
private void ConfigureBindingSources()
{
_authenticationBS.DataSource = _authentications;
}
private void ConfigureBindingManagers()
{
_authenticationCBM.BindingSource = _authenticationBS;
}
#region LoadSupportingData
public void LoadSupportingData()
{
LoadAuthentications();
}
private void LoadAuthentications()
{
_authentications.ReplaceRange(_entityManager.AUTHENTICATIONs.Where(e => e.AUTHENTICATION_IS_ACTIVE));
_authentications.Add(_entityManager.GetNullEntity<AUTHENTICATION>());
_authentications.ApplySort(AUTHENTICATION.PathFor(e => e.AUTHENTICATION_DISPLAY_ORDER), ListSortDirection.Ascending,true);
}
# endregion
#region Private Fields
DomainModelEntityManager _entityManager =
DomainModelEntityManager.DefaultManager;
BindableList<AUTHENTICATION> _authentications = new BindableList<AUTHENTICATION>();
#endregion
}
}
If any one knows of a faster way please let me know.
|