This is a migrated thread and some comments may be shown as answers.

Changing Datafield Control in autogenerating event

4 Answers 111 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
David Ocasio asked on 17 Mar 2011, 11:36 AM

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

4 Answers, 1 is accepted

Sort by
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 17 Mar 2011, 01:24 PM
i see
just need to set the binding after creating the datafield

thanks
dco
0
Pavel Pavlov
Telerik team
answered on 21 Mar 2011, 11:07 AM
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
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 21 Mar 2011, 12:19 PM
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
0
Pavel Pavlov
Telerik team
answered on 22 Mar 2011, 02:23 PM
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
Tags
DataForm
Asked by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Pavel Pavlov
Telerik team
Share this question
or