How to add row in telerik radGridView dynamically?
I am using Telerik RadGridView control. I want to add row in radGridView in runtime. I use following code:
<telerikGrid:RadGridView x:Name="TopGrid" AutoGenerateColumns="False" >
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewComboBoxColumn DataMemberBinding="{Binding FieldName}" Width="150" Header="Field Name"/>
<telerikGrid:GridViewComboBoxColumn DataMemberBinding="{Binding Operator}" ItemsSource="{Binding OperatorList, Source={StaticResource OperatorModel}}" Width="150" Header="Operator"/>
</telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>
Can anyone hel开发者_StackOverflowp me?
Not sure what you're using as far as a datasource, but generally speaking you'd be binding the RadGridView to some ItemsSource, then the source for the combo box columns would come from there.
For example, with an entity:
public class SomeEntity
{
public string FieldName { get; set; }
public string Operator { get; set; }
}
Binding the RadGridView to the List would automatically generate rows for this, so adding a new entity to that list would generate a new row. More info on how you're binding/populating the grid would help me give a more specific answer. :)
精彩评论