Results 1 to 6 of 6

Thread: [Resolved]Displaying item on datagrid?

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    52

    [Resolved]Displaying item on datagrid?

    I've been trying to add an item to my datagrid but when I add one it just displays a blank row. When I use msgbox to see the item text it shows the value I want to display. So my question is, why doesn't the datagrid display "test"?

    Here's my vb:
    Code:
    Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    	'add columns to datagrid
    	Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn
    	linkColumn.Header = "Links:" : titleColumn.Header = "Titles:"
    	linkColumn.Width = DataGrid1.Width / 2 : titleColumn.Width = DataGrid1.Width / 2
    	linkColumn.Binding = New System.Windows.Data.Binding("Links") : titleColumn.Binding = New System.Windows.Data.Binding("Titles")
    	DataGrid1.Columns.Add(linkColumn) : DataGrid1.Columns.Add(titleColumn)
    
    	mainTimer.Interval = 5000 : mainTimer.Enabled = True
    
    	DataGrid1.Items.Add("test")
    	MsgBox(DataGrid1.Items.Item(0).ToString) 'although the datagrid won't show it, this displays "test". why?
    End Sub
    Not sure if it's needed to help me but here's my XAML:
    Code:
    <DataGrid AutoGenerateColumns="False" Height="289" HorizontalAlignment="Left" Margin="10,10,0,0" Name="DataGrid1" VerticalAlignment="Top" Width="481" Grid.ColumnSpan="2" ItemsSource="{Binding}" />
    Last edited by code; Sep 11th, 2012 at 12:18 PM. Reason: [Resolved]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width