我正在为NinjaTrader应用程序中的窗口编写一些工具栏代码。我的按钮运行得很好,但无法找出实现组合框的正确语法。这是按钮的语法;
声明变量-------
private System.Windows.Forms.ToolStrip strip = null;
private System.Windows.Forms.Control[] controls = null;
private System.Windows.Forms.ToolStripButton btnHalt = null;
初始化按钮--------
ToolStripButton btnTemp = new System.Windows.Forms.ToolStripButton("temp");
boldFont = new Font("Arial", 8,FontStyle.Bold);
regularFont = new Font("Arial", 8);
btnTemp = null;
btnHalt = new System.Windows.Forms.ToolStripButton("btnHalt");
btnManual.Font = boldFont;
btnHalt.Font = regularFont;
btnHalt.ForeColor = Color.White;
btnHalt.BackColor = Color.Red;
btnHalt.Text = "Trading Off";
strip = (System.Windows.Forms.ToolStrip)controls[0];
strip.Items.Add(btnHalt);
btnHalt.Click += btnHalt_Click;
清理工具栏--------
public override void Dispose()
{
if (buttonsloaded==true)
{
strip.Items.Remove(btnHalt);
}
}
On_Click事件代码---------
private void btnHalt_Click(object sender, EventArgs e)
{
if (btnHalt.Text == "Trading Off")
{
btnHalt.Text = "Trading On";
btnHalt.Font = regularFont;
btnHalt.ForeColor = Color.White;
btnHalt.BackColor = Color.Green;
}
}
如果有人能告诉我组合框的正确语法,我会非常感激!
提前谢谢!