Simple WPF Datagrid Demo Or Tutorial
I have developed a project on WPF before. WPF has been utilized in Vista OS and other software. But this cannot replace the stability of Windows Forms.
Still, I don't have ample time to dive deeply in WPF, hopefully soon! LOL.. :D
So, to begin with:
1. Download and install WPF Toolkit (Visual Studio 2008)
2. Open Visual Studio 2008
3. Add a WPF Project (Just call it GridDemo)
4. Add a DataGrid in your Window.xaml
5. Make sure to have referenced wpf toolkit: http://schemas.microsoft.com/wpf/2008/toolkit/
6. Customize Your Grid
7. In your Window1.cs file, populate your grid with resulset
8. Run your application.
That's It!
Still, I don't have ample time to dive deeply in WPF, hopefully soon! LOL.. :D
So, to begin with:
1. Download and install WPF Toolkit (Visual Studio 2008)
2. Open Visual Studio 2008
3. Add a WPF Project (Just call it GridDemo)
4. Add a DataGrid in your Window.xaml
5. Make sure to have referenced wpf toolkit: http://schemas.microsoft.com/wpf/2008/toolkit/
6. Customize Your Grid
<grid:DataGrid AutoGenerateColumns="False" Margin="8,11,10,78" ItemsSource="{Binding}" Name="CusGrid"> <grid:DataGrid.Columns> <grid:DataGridTextColumn Binding="{Binding Path=CustomerID}" Header="Customer ID" /> </grid:DataGrid.Columns> ....other columns goes here </grid:DataGrid>
protected void GridLoad() { SqlConnection conn = new SqlConnection(your_connection_string); SqlCommand cmd = new SqlCommand("select * from customers",conn); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); CusGrid.DataContext = ds.Tables[0]; }
That's It!
Comments
Post a Comment