Created
August 23, 2014 07:03
-
-
Save KentaYamada/3e0c09a72b50eed2caea to your computer and use it in GitHub Desktop.
独自に定義したクラスのコレクションをDataGridViewへ格納、取得するサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Linq; | |
using System.Windows.Forms; | |
public class GenericsDataGridView : DataGridView | |
{ | |
public ExDataGridView() | |
: base() | |
{ } | |
///<summary>データ格納</summary> | |
public void SetData<T>(List<T> list) where T : class | |
{ | |
base.DataSource = new BindingList<T>(list); | |
} | |
///<summary>データ取得</summary> | |
public List<T> GetData<T>() where T : class | |
{ | |
return (base.DataSource as BindingList<T>).ToList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment