I am using datagridview (not datagrid) in my wpf application and i use this code to call it in my Window
<Window x:Class="TestHosting.MainWindow"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="440.132" Width="521.053">
<Grid>
<WindowsFormsHost Margin="20,20,130,142">
<wf:DataGridView x:Name="dgv">
<wf:DataGridView.Columns>
<wf:DataGridViewColumn Name="column1" HeaderText="Col l" />
<wf:DataGridViewColumn Name="column2" HeaderText="Col 2"/>
<wf:DataGridViewColumn Name="column3" HeaderText="Col 3"/>
</wf:DataGridView.Columns>
</wf:DataGridView>
</WindowsFormsHost>
and the problem is that an error says that "At Least on of the datagridview controls' columns has no cell template."
how should I fix this error ?
You could use DataGrid , instead of DataGridView
SqlDataAdapter da = new SqlDataAdapter("Select * from Table", con);
DataTable dt = new DataTable("Call Reciept");
da.Fill(dt);
DataGrid dg = new DataGrid();
dg.ItemsSource = dt.DefaultView;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.