Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created April 11, 2012 02:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaru-b-cl/2356471 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/2356471 to your computer and use it in GitHub Desktop.
BindingSourceのカレント行の項目を型安全にを取得するためのヘルパ拡張メソッド
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;
}
}
}
@masaru-b-cl
Copy link
Author

DataRow以外にも対応

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment