您的位置:首页 > 其它

Revit 2011二次开发“弹出对话框,得到输入的值”

2011-03-11 15:25 357 查看
新建一个窗体FrmDlg.cs



编辑框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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: