Ok so yes working my way through WPF and a struggle lol. But so far I agree it is worth it @Skydiver thanks.
ok so I can bind my database with a Datagrid and get it to display but when I work with the list box i get all turned around for some reason. But the Datagrid is a bit more to my liking on the partial look of it.
ok so I can bind my database with a Datagrid and get it to display but when I work with the list box i get all turned around for some reason. But the Datagrid is a bit more to my liking on the partial look of it.
MainWindow.xaml:
<DataGrid Margin="5,0,5,0" Name="ReportFilter" Grid.Row="2" Grid.RowSpan="15"
Grid.Column="3" >
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Width=" 10"/>
</DataGrid.Columns>
</DataGrid>
mainWindows.xaml.cs:
public MainWindow()
{
InitializeComponent();
bindListBox();
}
private void bindListBox()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select closeid, e_date from [closeout]";
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable("Closeout");
da.Fill(dt);
ReportFilter.ItemsSource = dt.DefaultView;
Last edited: