对基于Windows的应用程序中Web应用程序中的相应代码的疑问 [英] doubt about corresponding code in web application to windows based application

查看:56
本文介绍了对基于Windows的应用程序中Web应用程序中的相应代码的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个在Web应用程序中能很好运行的代码

hi all

I have a code in which works well in web application

private void AddTopMenuItems(DataTable menuData)
{
    DataView view = new DataView(menuData);
    view.RowFilter = "ParentId IS NULL";
    foreach (DataRowView row in view)
    {
        MenuItem newMenuItem = new MenuItem(row["Name_tb"].ToString(), row["CategoryId"].ToString());
        Menu1.Items.Add(newMenuItem);
        AddChildMenuItems(menuData, newMenuItem);
    }

}


但是在基于Windows的应用程序中使用此代码时,在行中出现错误


but when using this code in windows based application error arising in lines

MenuItem newMenuItem = new MenuItem(row["Name_tb"].ToString(), row["CategoryId"].ToString());




and

menuStrip1.Items.Add(newMenuItem);


错误消息是


errors messages are

The best overloaded method match for 'System.Windows.Forms.MenuItem.MenuItem(string, System.EventHandler)' has some invalid arguments	





and

The best overloaded method match for 'System.Windows.Forms.ToolStripItemCollection.Add(System.Windows.Forms.ToolStripItem)' has some invalid arguments


如何在Windows


how to do this web application code in windows

推荐答案

中执行此Web应用程序代码.错误消息非常清楚.在情况1中,您将传递字符串作为第二个参数而不是System.EventHandler.检查 MSDN [
The error messages are quite clear. In case 1 you are passing a string as the second parameter instead of a System.EventHandler. Check the MSDN[^] documentation for the correct argument types.


这篇关于对基于Windows的应用程序中Web应用程序中的相应代码的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆