【问题标题】:Single click on button not working but double click does the work in C# revit API单击按钮不起作用,但双击在 C# revit API 中起作用
【发布时间】:2021-02-11 05:23:36
【问题描述】:

当我从我的 FORM 中单击按钮时,单击按钮不起作用,但双击起作用。

请帮助我,如何解决并让我知道原因。 enter image description here

设计师代码是

            // searchButton
            // 
            this.searchButton.Cursor = System.Windows.Forms.Cursors.Hand;
            this.searchButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.searchButton.Location = new System.Drawing.Point(100, 144);
            this.searchButton.Name = "searchButton";
            this.searchButton.Size = new System.Drawing.Size(97, 31);
            this.searchButton.TabIndex = 0;
            this.searchButton.Text = "Search";
            this.searchButton.UseVisualStyleBackColor = true;
            this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
            // 

【问题讨论】:

  • 欢迎来到 StackOverflow。我们中的一些人看不到图像。你能编辑嵌入它吗?

标签: c# revit-api


【解决方案1】:

使用 MouseClick 事件而不是 Click 事件

this.searchButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.searchButton_Click);

【讨论】:

  • 谢谢,Hokage,但仍然无法正常工作,我必须做其他事情
  • 糟糕,您是否也将object sender, EventArgs e 作为参数放入了searchButton_Click 函数中?
  • 是的,私有 void searchButton_MouseClick(object sender, EventArgs e)
  • 我检查了按钮属性并且 MouseEnter 是空的,然后我用 button_Click 填充它。它现在正在工作。谢谢,火影
猜你喜欢
  • 1970-01-01
  • 2023-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-02
相关资源
最近更新 更多