我下面這正是:自定義項目模板嚮導按鈕點擊不會觸發?
http://msdn.microsoft.com/en-us/library/ms185301.aspx
,但不能讓它開始工作。當我嘗試添加新項目時出現窗體,但是當我輸入文本並單擊按鈕時,沒有任何反應。
爲後人的緣故,這裏是我的代碼:
在一個延伸向導類的非空方法IWizard
public void RunStarted(object automationObject,
Dictionary<string, string> replacementsDictionary,
WizardRunKind runKind, object[] customParams)
{
try
{
// Display a form to the user. The form collects
// input for the custom message.
inputForm = new UserInputForm();
inputForm.ShowDialog();
customMessage = inputForm.get_CustomMessage();
// Add custom parameters.
replacementsDictionary.Add("$custommessage$",
customMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
// This method is only called for item templates,
// not for project templates.
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
用戶輸入表單代碼:
public partial class UserInputForm : Form
{
private string customMessage;
public UserInputForm()
{
InitializeComponent();
}
public string get_CustomMessage()
{
return customMessage;
}
private void button1_Click(object sender, EventArgs e)
{
customMessage = textBox1.Text;
this.Dispose();
}
}
而按鈕確實命名爲按鈕1:
this.button1.Location = new System.Drawing.Point(200, 180);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 40);
this.button1.TabIndex = 0;
this.button1.Text = "Click Me";
this.button1.UseVisualStyleBackColor = true;
所以我沒有太多的Windows窗體(做網絡應用程序)的經驗,但我遵循MSDN上的方向,這是相當明確的削減。有什麼建議麼?任何人都可以得到這個工作?
只是旁註:請記住在將程序集添加到GAC後再次重新啓動VS – user65439 2014-05-27 11:31:41