Hi,
I'm trying to import a MS Access database to a SFDataGrid, since I'd like to use the filter and sorting for this control. I got it working for a WPF DataGrid using the tutorial
here and then build the project, go to the Data Sources toolbar, make sure DataGrid is selected from the dropdown for the dataset and then drag and drop into the design view. I was unable to figure out how to add the SFDataGrid control as a custom control for this dataset (under Customized Control Binding). I have the code below after messing around with the DataGrid code, but it doesn't display any data -- only the headers.
What is the best way to import a MS Access database into a SFDataGrid?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:AccessWPFTest" x:Class="AccessWPFTest.MainWindow"
Title="MainWindow"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="1080"
Loaded="Window_Loaded" >
<Page.Resources>
<local:TestDatabaseDataSet x:Key="testDatabaseDataSet"/>
<CollectionViewSource x:Key="test_1ViewSource" Source="{Binding Test_1, Source={StaticResource testDatabaseDataSet}}"/>
</Page.Resources>
<Grid DataContext="{StaticResource test_1ViewSource}">
<syncfusion:SfDataGrid x:Name="test_1DataGrid" ColumnSizer="Auto" ItemsSource="{Binding test_1ViewSource}" >
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn x:Name="number" HeaderText="Number" Binding.XmlNamespaceManager="{Binding Number}"/>
<syncfusion:GridTextColumn x:Name="number2" HeaderText="Number2" Binding.XmlNamespaceManager="{Binding Number2}"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
</Grid>
</Page>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AccessWPFTest.TowerDatabaseDataSet towerDatabaseDataSet = ((AccessWPFTest.TowerDatabaseDataSet)(this.FindResource("towerDatabaseDataSet")));
// Load data into the table TW230kV_1. You can modify this code as needed.
AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter towerDatabaseDataSetTW230kV_1TableAdapter = new AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter();
towerDatabaseDataSetTW230kV_1TableAdapter.Fill(towerDatabaseDataSet.TW230kV_1);
System.Windows.Data.CollectionViewSource tW230kV_1ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tW230kV_1ViewSource")));
tW230kV_1ViewSource.View.MoveCurrentToFirst();
}