Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a datatable to a WPF datagrid C#?
    primarykey
    data
    text
    <p>I'm new to c# so go easy.</p> <p>Basically I build a data table ( and I have verified it's not empty) but it doesn't seem to get displayed in my wpf datagrid... I used this example here and applied it:<a href="http://social.msdn.microsoft.com/Forums/en/wpf/thread/d04229ba-3c96-4aa7-a386-7cd1ce5eedea" rel="nofollow">link text</a></p> <p>My datagrid remains blank.</p> <p>Does that example look fine to you guys?</p> <p>here is my code:</p> <p>XACML:</p> <pre><code>&lt;Window x:Class="WpfApplication1.TickerSearch" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TickerSearch" Height="468" Width="907"&gt; &lt;Grid Background="#E6000000" Name="_grid"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="244*" /&gt; &lt;ColumnDefinition Width="37*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBox Height="34" HorizontalAlignment="Left" Margin="26,15,0,0" Name="txtSearchTker" VerticalAlignment="Top" Width="225" Grid.ColumnSpan="2" /&gt; &lt;Button Content="Search" Height="32" HorizontalAlignment="Left" Margin="76,160,0,0" Name="btnSearch" VerticalAlignment="Top" Width="124" Click="btnSearch_Click" /&gt; &lt;ListBox Height="114" HorizontalAlignment="Left" Margin="26,224,0,0" Name="lstResults" VerticalAlignment="Top" Width="225" Visibility="Hidden" Grid.ColumnSpan="2" Background="#FFFFB000" /&gt; &lt;Button Content="Select" Height="32" HorizontalAlignment="Left" Margin="76,366,0,0" Name="btnSelect" VerticalAlignment="Top" Width="124" Visibility="Hidden" /&gt; &lt;Label Content="Start Date: " Height="25" HorizontalAlignment="Left" Margin="22,65,0,0" Name="label1" VerticalAlignment="Top" Width="71" Background="#00FFB000" FontFamily="Georgia" Foreground="#FFFFB000" /&gt; &lt;Label Content="End Date:" Height="27" HorizontalAlignment="Left" Margin="22,93,0,0" Name="label2" VerticalAlignment="Top" Width="71" Background="#00FFB000" FontFamily="Georgia" Foreground="#FFFFB000" /&gt; &lt;DatePicker Height="22" HorizontalAlignment="Left" Margin="93,65,0,0" Name="dateFrom" VerticalAlignment="Top" Width="138" /&gt; &lt;DatePicker Height="22" HorizontalAlignment="Left" Margin="93,94,0,0" Name="toDate" VerticalAlignment="Top" Width="138" /&gt; &lt;Label Content="Just Today" Height="27" HorizontalAlignment="Left" Margin="22,122,0,0" Name="label3" VerticalAlignment="Top" Width="71" Background="#00FFB000" FontFamily="Georgia" Foreground="#FFFFB000" /&gt; &lt;CheckBox Content="CheckBox" Height="17" HorizontalAlignment="Left" Margin="93,127,0,0" Name="chkBoxToday" VerticalAlignment="Top" Width="15" /&gt; &lt;DataGrid AutoGenerateColumns="False" Height="315" HorizontalAlignment="Left" Margin="285,68,0,0" x:Name="_dataGrid" VerticalAlignment="Top" Width="468" ItemsSource="{Binding Path=.}" Background="#C6F7F700"&gt;&lt;/DataGrid&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>c#:</p> <pre><code> _ds = new DataSet(); DataTable table = yahooFinance.lookupSymbol(); _ds.Tables.Add(table); _grid.DataContext = _ds.Tables[0]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload