用ComboBox控件来编辑C#中ListView控件中数据,提示这个错误怎么解决??

wandingwei 2011-03-07 06:27:01
就是按照网上流传的这个方法,但是每次都提示

错误 1 “WindowsControlLibrary4.UserControl1.Dispose(bool)”: 没有找到适合的方法来重写 E:\工作\ERP\牡丹考核\ListView中Combobox实验\WindowsControlLibrary4\WindowsControlLibrary4\UserControl1.Designer.cs 14 33 WindowsControlLibrary4

不知道这个该怎么改,还望多多指教!!!

*****************************************************************************************
创建继承 ListView 控件

1. 启动 MicrosoftVisualStudio.NET 或 Microsoft Visual Studio 2005。

2. 在文件菜单, 指向新建 , 然后单击项目 。

3. 在新建项目 对话框中, 单击 ProjectTypes@@ , 下VisualC #项目,然后单击模板下WindowsControlLibrary@@ 。
注意 对于 Visual Studio 2005, 单击 项目类型 下 VisualC # 。

4. 用以下代码替换所有 UserControl 类中代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace InheritedListView{
  /// <summary>
  /// Summary description for UserControl1.
  /// </summary>
  public class MyListView : System.Windows.Forms.ListView
  {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    public MyListView()
    {
      // This call is required by the Windows.Forms Form Designer.
      InitializeComponent();
      // TODO: Add any initialization after the InitForm call
    }
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if( components != null )
        components.Dispose();
      }
      base.Dispose( disposing );
    }
    #region Component Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      components = new System.ComponentModel.Container();
    }
    #endregion
    private const int WM_HSCROLL = 0x114;
    private const int WM_VSCROLL = 0x115;
    protected override void WndProc(ref Message msg)
    {
      // Look for the WM_VSCROLL or the WM_HSCROLL messages.
      if ((msg.Msg == WM_VSCROLL) || (msg.Msg == WM_HSCROLL))
      {
        // Move focus to the ListView to cause ComboBox to lose focus.
        this.Focus();
      }
      // Pass message to default handler.
      base.WndProc(ref msg);
    }
  }
}

***********************************************************

UserControl1.Designer.cs 中的代码是这样的。。

namespace WindowsControlLibrary4
{
partial class UserControl1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region 组件设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}

#endregion
}
}


...全文
99 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xingyuebuyu 2011-03-07
  • 打赏
  • 举报
回复
可以直接删掉文件UserControl1.Designer.cs
wandingwei 2011-03-07
  • 打赏
  • 举报
回复
有人遇到过这个么。。
wandingwei 2011-03-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 cf370697816 的回复:]
太多了。。
[/Quote]

有的人说是命名空间的问题,我都改成一致了,也不行

错误出在Dispose这个函数上。。
cf370697816 2011-03-07
  • 打赏
  • 举报
回复
太多了。。

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧