【发布时间】:2018-05-29 01:48:33
【问题描述】:
有谁知道为什么这些控件没有显示在表单上?如果我通过设计添加具有相同属性的控件,一切正常,但如果我在表单构造函数中使用来自设计器的相同代码,只有其他名称,则没有任何作用。
private void CreatePlayingTab()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
//
// bunifuCustomLabel_Titel
//
BunifuCustomLabel bunifuCustomLabel_Titel = new BunifuCustomLabel();
bunifuCustomLabel_Titel.AutoSize = true;
bunifuCustomLabel_Titel.Font = new Font("Century Gothic", 11.25F, FontStyle.Bold, GraphicsUnit.Point, 0);
bunifuCustomLabel_Titel.ForeColor = Color.FromArgb(224, 224, 224);
bunifuCustomLabel_Titel.Location = new Point(19, 30);
bunifuCustomLabel_Titel.Name = "bunifuCustomLabel_Titel";
bunifuCustomLabel_Titel.Size = new Size(153, 18);
bunifuCustomLabel_Titel.Text = "#001 Wer ist Naruto?";
//
// bunifuCustomLabel_Interpret
//
BunifuCustomLabel bunifuCustomLabel_Interpret = new BunifuCustomLabel();
bunifuCustomLabel_Interpret.AutoSize = true;
bunifuCustomLabel_Interpret.Font = new Font("Century Gothic", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0);
bunifuCustomLabel_Interpret.ForeColor = Color.FromArgb(224, 224, 224);
bunifuCustomLabel_Interpret.Location = new Point(20, 52);
bunifuCustomLabel_Interpret.Name = "bunifuCustomLabel_Interpret";
bunifuCustomLabel_Interpret.Size = new Size(98, 20);
bunifuCustomLabel_Interpret.Text = "Studio Tokyo";
//
// windowsMediaPlayer
//
AxWindowsMediaPlayer windowsMediaPlayer = new AxWindowsMediaPlayer();
windowsMediaPlayer.Dock = DockStyle.Bottom;
windowsMediaPlayer.Enabled = true;
windowsMediaPlayer.Location = new Point(0, 117);
windowsMediaPlayer.Name = "windowsMediaPlayer";
windowsMediaPlayer.OcxState = ((AxHost.State)(resources.GetObject("mediaPlayer.OcxState")));
windowsMediaPlayer.Size = new Size(912, 513);
windowsMediaPlayer.uiMode = "None";
//
// panel_currentlyPlaying
//
Panel panel_currentlyPlaying = new Panel();
panel_currentlyPlaying.Controls.Add(windowsMediaPlayer);
panel_currentlyPlaying.Controls.Add(bunifuCustomLabel_Titel);
panel_currentlyPlaying.Controls.Add(bunifuCustomLabel_Interpret);
panel_currentlyPlaying.Dock = DockStyle.Fill;
panel_currentlyPlaying.Location = new Point(0, 100);
panel_currentlyPlaying.Name = "panel_Playing";
panel_currentlyPlaying.Size = new Size(912, 630);
panel_Media.Controls.Add(panel_currentlyPlaying);
}
【问题讨论】:
-
可能
panel_Media没有添加到表单或不可见或超出表单边界,我们在代码中看不到。 -
您正在将“mediaPlayer”添加到 panel_currentlyPlaying ...但您创建的 AxWindowsMediaPlayer 实例名为“windowsMediaPlayer”
-
是的,这是一个错误。现在更改它只有 mediaPlayer 可见,但标签不可见。
-
我刷新了问题
-
还有其他人的想法吗?