我写了一个扩展方法断的DataGridView称为HideColumns。
I have written an Extension Method off of DataGridView called HideColumns.
public static class Extensions
{
public static void HideColumns(this DataGridView dataGridView, params string[] columnNames)
{
foreach (string str in columnNames)
{
if (dataGridView.Columns[str] != null)
{
dataGridView.Columns[str].Visible = false;
}
}
}
}
我通过我的网格到IronRuby的脚本变量称为main_grid
I pass my grid into an IronRuby script as a variable called main_grid
在我的脚本调用 main_grid.HideColumns(名字,姓氏) 脚本炸毁在脚本错误 未定义的方法'HideColumns为System.Windows.Forms.DataGridView:系统:视窗:形式:DataGridView的
When my script calls main_grid.HideColumns("FirstName","LastName") the script blows up with Error in Script undefined method 'HideColumns' for System.Windows.Forms.DataGridView:System::Windows::Forms::DataGridView
的扩展方法似乎工作从C#还行。是什么给了?
The extension methods seem to work okay from C#. What gives?
FWIW,IronRuby的1.1(需要.NET 4)提供了 using_clr_extensions
方法 - 如指出的发行说明此激活在一个给定的命名空间中定义的类中定义的所有扩展方法,而不管它们是在定义的组件;在未来加载的程序集定义在启动命名空间的扩展方法会自动出现在正确的类型,像这样的:
FWIW, IronRuby 1.1 (needs .net 4) provides the using_clr_extensions
method -- as noted in the release notes this activates all extension methods defined on classes defined in a given namespace, regardless of the assembly they are defined in; assemblies loaded in the future that define extension methods in the activated namespace will automatically appear on the correct types, like this:
load_assembly "System.Core"
using_clr_extensions System::Linq
# ...
products.
where(lambda { |p| p.units_in_stock == 0 }).
each { |x| puts x.product_name }
的发行说明也指向了一整套的例子在的http://github.com/ironruby/ironruby/blob/master/Languages/Ruby/Samples/Linq/101samples.rb
上一篇:如何使.EXE示范Eclipse内置的一款Android软件?软件、EXE、Eclipse、Android
下一篇:如何与谷歌的小号preadsheet连接Android应用程序小号、应用程序、preadsheet、Android