Created
April 11, 2012 02:33
-
-
Save masaru-b-cl/2356471 to your computer and use it in GitHub Desktop.
BindingSourceのカレント行の項目を型安全にを取得するためのヘルパ拡張メソッド
This file contains 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; | |
using System.Data; | |
using System.Windows.Forms; | |
namespace WindowsFormsApplication1 | |
{ | |
public static class BindingSourceExtensions | |
{ | |
public static T GetCurrent<T>(this BindingSource bs) where T : class | |
{ | |
var current = bs.Current; | |
var drv = current as DataRowView; | |
if (drv != null) | |
{ | |
return drv.Row as T; | |
} | |
return current as T; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DataRow以外にも対応