Add An Item To WPF Datagrid (VB.NET)
Hello!
C# Version: Adding An Item to WPF Datagrid (C#)
There was a question on visual basic forum on how to add an item to a wpf datagrid. Here's a simple example below.
Code view:
XAML:
VB.NET Class
That's it... :)
C# Version: Adding An Item to WPF Datagrid (C#)
There was a question on visual basic forum on how to add an item to a wpf datagrid. Here's a simple example below.
Code view:
Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn linkColumn.Header = "Links:" : titleColumn.Header = "Titles:" linkColumn.Width = dataGrid.Width / 2 : titleColumn.Width = dataGrid.Width / 2 linkColumn.Binding = New System.Windows.Data.Binding("Link") : titleColumn.Binding = New System.Windows.Data.Binding("Title") dataGrid.Columns.Add(linkColumn) : dataGrid.Columns.Add(titleColumn) dataGrid.Items.Add(New DataItems() With {.Link = "http://testingme.com", .Title = "mytesting"})
<DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid" VerticalAlignment="Top" Width="481" Grid.ColumnSpan="2" ItemsSource="{Binding }"> </DataGrid>
Private _link As String Public Property Link() As String Get Return _link End Get Set(ByVal l As String) _link = l End Set End Property Private _title As String Public Property Title() As String Get Return _title End Get Set(ByVal t As String) _title = t End Set End Property
That's it... :)
Comments
Post a Comment