Код: Выделить всё
using System.Windows.Forms;
using System.Drawing;
namespace GoPlanner
{
public partial class GoPlanner : Form
{
private void InitPlayReplay() // called from main form start up code
{
Panel prpPanel = new Panel
{
Width = 500,
Height = toolStrip1.Height,
BackColor = Color.Black,
Visible = true
};
Button butTest = new Button // NOT SUGGESTED BY CP
{
Width = 50,
Height = toolStrip1.Height,
BackColor = Color.Black
};
ToolStripControlHost host = new ToolStripControlHost(prpPanel);
toolStrip1.Items.Add(host);
prpPanel.Paint += CustomPanel_Paint;
prpPanel.MouseClick += CustomPanel_MouseClick;
butTest.MouseClick += CustomPanel_MouseClick;
}
private void CustomPanel_Paint(object sender, PaintEventArgs e)
{
MessageBox.Show("Paint!");
}
private void CustomPanel_MouseClick(object sender, MouseEventArgs e)
{
MessageBox.Show("Panel clicked!");
}
}
}
Когда я изменил
Код: Выделить всё
ToolStripControlHost host = new ToolStripControlHost(prpPanel);Код: Выделить всё
ToolStripControlHost host = new ToolStripControlHost(butTest);Что еще мне нужно, чтобы панель появилась?
По сути, мне нужен элемент управления, который можно рисовать, как панель.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ual-studio
Мобильная версия