Announcement

Collapse
No announcement yet.

PropertyGrid und dynamische Aufzählung aus DB

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Ralf Jansen View Post
    Zeig mal deine aktuelle EditValue Implementierung.

    Den TypeConverter hast du nicht auch noch an der Property hängen oder? Du brauchst im Moment nur den UITypeEditor.
    Hab den TypeConverter zwar grad erst abgehängt, aber trotzdem wird im PG die GUID angezeigt

    [highlight=vbnet] Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
    Dim _SelectValue As String = System.Guid.Empty.ToString

    If context Is Nothing _
    OrElse provider Is Nothing _
    OrElse context.Instance Is Nothing Then
    Return MyBase.EditValue(provider, value)
    End If

    Try
    edSvc = CType(provider.GetService(GetType(IWindowsFormsEdi torService)), IWindowsFormsEditorService)

    ' Wenn die Instanzierung erfolgreich war
    If edSvc IsNot Nothing = True Then

    Dim _Control As XListBox = New XListBox ' erweitertes UserControl, damit man IdemData nutzen kann
    Dim _dtCongregations As New MYKEY.CongAdminFX.Common.dsCongAdminCongregations. CongAdminFXCongregationsDataTable
    Dim _adCongregations As MYKEY.CongAdminFX.Common.dsCongAdminCongregationsT ableAdapters.CongAdminFXCongregationsTableAdapter
    Dim _rowCongregations As MYKEY.CongAdminFX.Common.dsCongAdminCongregations. CongAdminFXCongregationsRow

    ' Auslesen der Daten aus der Datenbank
    _adCongregations = New MYKEY.CongAdminFX.Common.dsCongAdminCongregationsT ableAdapters.CongAdminFXCongregationsTableAdapter
    With _adCongregations
    .Connection.ConnectionString = MYKEY.FX.Interface.Application.DB_CONNECTION
    .Fill(_dtCongregations)
    End With

    ' Anpassen und Füllen der Listbox
    AddHandler _Control.MouseDoubleClick, AddressOf XList_MouseDoubleClick

    If _dtCongregations.Rows.Count > 0 Then
    For Each _rowCongregations In _dtCongregations.Rows
    Controls.VB2005.AddListBoxItem(_Control, _rowCongregations.CongName, _rowCongregations.CongGUID)
    Next
    End If

    ' Öffnen und anzeigen der Liste zur Auswahl
    edSvc.DropDownControl(_Control)

    ' Ermitteln des Wertes, der geschrieben werden soll
    _SelectValue = Controls.VB2005.GetItemData(_Control, _Control.SelectedIndex)

    End If

    Catch ex As Exception
    Throw New Exception("Error in EditValue Routine")
    End Try

    Return _SelectValue

    End Function[/highlight]
    Zuletzt editiert von MyKey0815; 27.05.2010, 12:09.

    Comment


    • #17
      Hab den TypeConverter zwar grad erst abgehängt, aber trotzdem wird im PG die GUID angezeigt
      Ja dummer Gedanke von mir. Sieh meinen letzten Beitrag. Ich hatte dein Problem nicht gleich durchschaut.

      Comment


      • #18
        Originally posted by Ralf Jansen View Post
        Ja dummer Gedanke von mir. Sieh meinen letzten Beitrag. Ich hatte dein Problem nicht gleich durchschaut.
        Ja, jetzt klappt es - Danke für deine Mithilfe. War sehr lehrreich.

        Comment

        Working...
        X