Changing Datafield Control in autogenerating event

5 posts, 0 answers
  1. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    May be doing this wrong
    but i assume the purpose of exposing the datafield is being able to replace with a more appropiate or complex type
    unfortunately it seems to loose its binding and dataannotations (label and description)

    Private Sub dfRangeSelector_AutoGeneratingField(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs) Handles dfRangeSelector.AutoGeneratingField
        Select Case e.PropertyName
            Case "StartDate"
                e.DataField = New Telerik.Windows.Controls.DataFormComboBoxField
        End Select

    thanks
    dco
  2. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 17 Mar 2011 Link to this post

    i see
    just need to set the binding after creating the datafield

    thanks
    dco
  3. DevCraft banner
  4. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Mar 2011 Link to this post

    Hi David,

    I am attaching a small sample which I believe does what you are trying to achieve (placing a combo box field ) .

    Greetings,
    Pavel Pavlov
    the Telerik team
  5. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 21 Mar 2011 Link to this post

    Thanks pavel for the sample

    I ended up doing a similar thing

    Instead i replaced the content member of the existing datafield with a combobox

    It there any advantage in replacing the datafield
    with the DataFormComboBoxField as opposed to setting the content property
    Is it considered better "Form"

    just wondering
    dco
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Mar 2011 Link to this post

    Hi David Ocasio,

    Both approaches are good.  Indeed we allow direct setting/replacing the content for more flexibility. However letting the field to initialize its content generally is better as all neccessary bindings, initialization etc. are done automatically .

    Best wishes,
    Pavel Pavlov
    the Telerik team
Back to Top
DevCraft banner