Information générale
Catégorie:
The Mere Mortals .NET Framework
I am trying to get a mmCombobox which is on a form inheriting from mmBusinessForm to display data. At this point, I am not even trying to bind the selected value to anything. Anyway, I have written the code to register the business object and then set the BindingSource, BindingSourceDisplayMember,BindingSourceValueMember. I have tested the Biz object via NUnit, and even added a message box into the initialization of the form where the biz object is specified to ensure that the CurrentDataset.Tables(0) has data(and it does).
I have also tried inheriting from the mmCombobox and doing the data access in the derived class and had the same results, nothing in combobox to choose from. Below is the code for one of the ways I have tried. Maybe someone else can tell me what I am doing wrong in this form.
Public Class TestComboDatabinding
Inherits OakLeaf.MM.Main.Windows.Forms.mmBusinessForm
Protected biz As New Csi.Biz.States
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
biz = CType(Me.RegisterPrimaryBizObj(New Csi.Biz.States), Csi.Biz.States)
System.Windows.Forms.MessageBox.Show(biz.GetCurrentDataSet().Tables(0).Rows.Count)
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents MmComboBox1 As OakLeaf.MM.Main.Windows.Forms.mmComboBox
Private Sub InitializeComponent()
Me.MmComboBox1 = New OakLeaf.MM.Main.Windows.Forms.mmComboBox
Me.SuspendLayout()
'
'MmComboBox1
'
Me.MmComboBox1.AutoDisabledList = False
Me.MmComboBox1.AutoDisabledValue = False
Me.MmComboBox1.BindingSource = "Csi.Biz.States"
Me.MmComboBox1.BindingSourceDisplayMember = "State.Description"
Me.MmComboBox1.BindingSourceValueMember = "State.StateCode"
Me.MmComboBox1.BindingValueSource = Nothing
Me.MmComboBox1.BindingValueSourceMember = Nothing
Me.MmComboBox1.ControlID = New System.Guid("00000000-0000-0000-0000-000000000000")
Me.MmComboBox1.Location = New System.Drawing.Point(72, 24)
Me.MmComboBox1.Name = "MmComboBox1"
Me.MmComboBox1.Size = New System.Drawing.Size(121, 21)
Me.MmComboBox1.TabIndex = 0
Me.MmComboBox1.ToolTipText = Nothing
Me.MmComboBox1.ValueBinding = Nothing
'
'TestComboDatabinding
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.MmComboBox1)
Me.Name = "TestComboDatabinding"
Me.ResumeLayout(False)
End Sub
#End Region
End Class
I have also tried passing in a previously instantiated biz object into the registerprimaryobject method as shown below. The results were the same 64 rows in datatable, but no rows in mmComboBox.
System.Windows.Forms.MessageBox.Show(biz.GetCurrentDataSet().Tables(0).Rows.Count)
Me.RegisterPrimaryBizObj(biz)
Any help would be greatly appreciated. Thanks.
Joe
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement