To pass values from the command to the dialog box, you can use the parameters of the constructor of the form (you will overload it accordingly).
And to pass the values specified by the user in the dialog box to the command, you can define properties in the class of the form whose values will be accessible via the instance of the form created in the command.
This is some basical OOP practice you should learn before trying to program AutoCAD.
A trivial example with some comments.
The DialogBox class:
using System.Windows.Forms;
namespace SimpleDialogSample
{
/// <summary>
/// Describes a dialog box which only contains:
/// - a Label (label1)
/// - a Textbox (textBox1)
/// - a OK button (buttonOK with DialogResult = OK)
/// - a Cancle button (buttonCancle with DialogResult = Cancel)
/// </summary>
public partial class DialogBox : Form
{
/// <summary>
/// Creates a new instance of DialogBox.
/// </summary>
/// <param name="label">Value of the label to display.</param>
public DialogBox(string label)
{
InitializeComponent();
// Assign the 'label' parameter value to label1.
label1.Text = label;
}
/// <summary>
/// Gets the textBox1.Text value.
/// </summary>
public string Content
{
get { return textBox1.Text; }
}
}
}
The Command class:
using Autodesk.AutoCAD.Runtime;
using System.Windows.Forms;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace SimpleDialogSample
{
public class Command
{
[CommandMethod("TEST")]
public static void Test()
{
// Creates a nes instance of DialogBox
using (var dialog = new DialogBox("Some text from the TEST CommandMethod"))
{
// Shows the dialog box and gets its DialogResult (i.e. the way it has been closed)
if (AcAp.ShowModalDialog(dialog) == DialogResult.OK)
{
// Shows the content which were entered in the dialog text box.
AcAp.ShowAlertDialog(
"The content of the dialog box TextBox is: " + dialog.Content);
}
else
{
AcAp.ShowAlertDialog("Cancellled");
}
}
}
}
}