Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGrid in WPF using VisualStudio C#
    primarykey
    data
    text
    <p>I have 3 <code>TexBox</code>es,<code>Button</code>s and <code>DataGrid</code> in my window. when I enter the data into the <code>TextBox</code> and click on the button it should add into the <code>DataGrid</code> .I need a code for how to add, delete and get data. I'm new to wpf please help me with the code. This is my Xaml code</p> <pre><code> &lt;Window x:Class="simpledatagrid.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="IDDATA" Height="350" Width="525"&gt; &lt;Grid &gt; &lt;DataGrid BorderBrush="Black" BorderThickness="2" AutoGenerateColumns="True" Name="dgsample" Margin="200,10,10,75"&gt;&lt;/DataGrid&gt; &lt;Label Content="ID :" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="26" Width="27"/&gt; &lt;Label Content="Name :" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" Height="26" Width="48"/&gt; &lt;Label Content="Salary :" HorizontalAlignment="Left" Margin="10,110,0,0" VerticalAlignment="Top" Height="26" Width="47"/&gt; &lt;TextBox Name="tb1" HorizontalAlignment="Left" Height="20" Margin="60,10,0,0" TextWrapping="NoWrap" Text="" VerticalAlignment="Top" Width="100"/&gt; &lt;TextBox Name="tb2" HorizontalAlignment="Left" Height="20" Margin="60,60,0,0" TextWrapping="NoWrap" Text="" VerticalAlignment="Top" Width="100"/&gt; &lt;TextBox Name="tb3" HorizontalAlignment="Left" Height="20" Margin="60,110,0,0" TextWrapping="NoWrap" Text="" VerticalAlignment="Top" Width="100"/&gt; &lt;Button Content="Get" HorizontalAlignment="Left" Margin="10,190,0,0" VerticalAlignment="Top" Width="75" Click="Get_Click" /&gt; &lt;Button Content="Add" HorizontalAlignment="Left" Margin="10,230,0,0" VerticalAlignment="Top" Width="75" Click="Add_Click" /&gt; &lt;Button Content="Delete" HorizontalAlignment="Left" Margin="10,270,0,0" VerticalAlignment="Top" Width="75" Click="Delete_Click" /&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>This is my .cs code</p> <pre><code>public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); List&lt;User&gt; users = new List&lt;User&gt;(); users.Add(new User() { Id = 101, Name = "gin", Salary = 10 }); users.Add(new User() { Id = 102, Name = "alen", Salary = 20 }); users.Add(new User() { Id = 103, Name = "scott", Salary = 30 }); dgsample.ItemsSource = users; } private void Get_Click(object sender, RoutedEventArgs e) { } private void Add_Click(object sender, RoutedEventArgs e) { } private void Delete_Click(object sender, RoutedEventArgs e) { } } } </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.
 

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