新建一个窗体FrmDlg.cs
Revit 2011二次开发“弹出对话框,得到输入的值”
编辑框txtVal
按钮btnOk
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RevitCodes
{
    
public partial class FrmDlg : Form
    {
        
public string Val
        {
            
get { return txtVal.Text; }
            
set { txtVal.Text = value; }
        }
        
public FrmDlg()
        {
            InitializeComponent();
        }

        
private void btnOk_Click(object sender, EventArgs e)
        {
            
this.DialogResult = DialogResult.OK;
        }
    }
}
调用
#region 弹出对话框,得到输入的值
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class GetDialogValue : IExternalCommand
{
    
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
    {
        FrmDlg frmDlg 
= new FrmDlg();
        frmDlg.ShowDialog();
        
if (frmDlg.DialogResult == DialogResult.OK)
        {
            MessageBox.Show(
"得到的值为:\n" + frmDlg.Val);
        }
        frmDlg.Dispose();
        
return Result.Succeeded;
    }
}
#endregion

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-09-17
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案