This question is locked. New answers and comments are not allowed.
Andreas Decke
Top achievements
Rank 1
Andreas Decke
asked on 16 Feb 2012, 09:58 PM
Hello,
in the original dataform, the label set to bold if the property is set to DataAnnatotion to [Required]. How can we do this in RadDataForm.
greetings Andreas
in the original dataform, the label set to bold if the property is set to DataAnnatotion to [Required]. How can we do this in RadDataForm.
greetings Andreas
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2012, 08:14 AM
Hello,
Try the following code.
C#:
Thanks,
Princy.
Try the following code.
C#:
private
void
dataForm_AutoGeneratingField(
object
sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
{
if
(e.PropertyName ==
"Name"
)
{
e.DataField.FontWeight = System.Windows.FontWeights.Bold;
}
}
Thanks,
Princy.
0
Andreas Decke
Top achievements
Rank 1
answered on 17 Feb 2012, 08:34 AM
Hello Princy,
this much is clear. How do I get the information that this property is [Required]. If I do this manually, Changed the Class property to be adjusted manually in the Auto-generating field. DataForm do this automatically.
greetings andreas
this much is clear. How do I get the information that this property is [Required]. If I do this manually, Changed the Class property to be adjusted manually in the Auto-generating field. DataForm do this automatically.
greetings andreas
0
Hello,
I am attaching a sample project illustrating the suggested approach.
Regards,
Maya
the Telerik team
Generally, you can try finding the properties that have Required attribute defined and again set FontWeight property of the corresponding data field. It could be something as follows:
private void clubsDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
{
var properties = this.clubsDataForm.CurrentItem.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in properties)
{
var requiredAttribute = propertyInfo.GetCustomAttributes(typeof(RequiredAttribute), true).FirstOrDefault();
if (requiredAttribute != null && e.PropertyName == propertyInfo.Name)
{
e.DataField.FontWeight = System.Windows.FontWeights.Bold;
}
}
}
I am attaching a sample project illustrating the suggested approach.
Regards,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Andreas Decke
Top achievements
Rank 1
answered on 22 Feb 2012, 08:51 AM
Hello,
wonderful, it works fine ..
thanks
wonderful, it works fine ..
thanks