첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

▶ 어셈블리 참조

Xceed Controls for WPF
Xceed DataGrid for WPF
Xceed DataGrid for WPF 3D Views
Xceed DataGrid for WPF Theme Pack #1
Xceed DataGrid for WPF Theme Pack #2

 

728x90

 

▶ MainApplication.Xaml

<Application
    x:Class="TestProject.MainApplication"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml">
</Application>

 

300x250

 

▶ MainApplication.Xaml.cs

using System;
using System.Data;
using System.Data.OleDb;
using System.Windows;

namespace TestProject
{
    /// <summary>
    /// 메인 애플리케이션
    /// </summary>
    public partial class MainApplication : Application
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 주문 테이블
        /// </summary>
        private static DataTable _orderTable;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 주문 테이블 - OrderTable

        /// <summary>
        /// 주문 테이블
        /// </summary>
        public static DataTable OrderTable
        {
            get
            {
                return _orderTable;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Static

        #region 생성자 - MainApplication()

        /// <summary>
        /// 생성자
        /// </summary>
        static MainApplication()
        {
            DataSet dataSet = new DataSet();

            string filePath = @"C:\DS.Core\DS.Test.SampleDatabase\nwind.mdb";

          //string connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", filePath); // MS Office 2007 버전 이후
            string connectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}" , filePath); // MS Office 2003 버전

            OleDbConnection  oleDbConnection  = new OleDbConnection(connectionString);
            OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter();

            oleDbDataAdapter.SelectCommand = new OleDbCommand("SELECT * FROM Orders;", oleDbConnection);

            oleDbDataAdapter.Fill(dataSet, "Order");

            _orderTable = dataSet.Tables["Order"];
        }

        #endregion
    }
}

 

▶ MainWindow.xaml

<Window
    x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
    Width="800"
    Height="600"
    Title="XCEED 그리드 사용하기">
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
        <Grid.Resources>
            <xcdg:DataGridCollectionViewSource
                x:Key="DataGridCollectionViewSourceKey"
                Source="{Binding Source={x:Static Application.Current},
                Path=Orders}" />
            </Grid.Resources>
            <xcdg:DataGridControl
                x:Name="dataGridControl"
                ItemsSource="{Binding Source={StaticResource DataGridCollectionViewSourceKey}}">
            </xcdg:DataGridControl>
    </Grid>
</Window>

 

▶ MainWindow.xaml.cs

using System.Windows;

using Xceed.Wpf.DataGrid;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.dataGridControl.ItemsSource = new DataGridCollectionView(MainApplication.OrderTable.DefaultView );
        }

        #endregion
    }
}

 

728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , , ,

댓글을 달아 주세요