无法获取菜单条上轨迹栏的值
我手动向菜单条添加了一个轨迹栏,因为 vs 2008 不允许我这样做。 但是,我无法获取轨迹栏的值。
Form1.cs:
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip |
ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class TrackBarMenuItem : ToolStripControlHost
{
private TrackBar trackBar;
public TrackBarMenuItem()
: base(new TrackBar())
{
this.trackBar = this.Control as TrackBar;
trackBar.TickFrequency = 1;
trackBar.Maximum = 255;
trackBar.LargeChange = 5;
trackBar.SmallChange = 2;
}
}
Form1.Designer.cs:
private TrackBarMenuItem trackBar1;
//
// trackBar1
//
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 25);
这就是我需要使用它的方式:
private void trackBar1_Scroll(object sender, System.EventArgs e)
{
int valueB = trackBar1.Value;
pictureBox2.Image = Deneme(new Bitmap(pictureBox1.Image),valueB);
}
但我收到此错误:
错误 1“goruntuIsleme2.Form1.TrackBarMenuItem”不包含 “Value”的定义,并且没有扩展方法“Value”接受 “goruntuIsleme2.Form1.TrackBarMenuItem”类型的第一个参数可以 被发现(您是否缺少 using 指令或程序集引用?)
有什么想法吗?
I've added a trackbar to menu strip manually because vs 2008 doesn't allow me to do.
However, i can't get the value of trackbar.
Form1.cs:
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip |
ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class TrackBarMenuItem : ToolStripControlHost
{
private TrackBar trackBar;
public TrackBarMenuItem()
: base(new TrackBar())
{
this.trackBar = this.Control as TrackBar;
trackBar.TickFrequency = 1;
trackBar.Maximum = 255;
trackBar.LargeChange = 5;
trackBar.SmallChange = 2;
}
}
Form1.Designer.cs:
private TrackBarMenuItem trackBar1;
//
// trackBar1
//
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 25);
and this is how i need to use it:
private void trackBar1_Scroll(object sender, System.EventArgs e)
{
int valueB = trackBar1.Value;
pictureBox2.Image = Deneme(new Bitmap(pictureBox1.Image),valueB);
}
but i get this error:
Error 1 'goruntuIsleme2.Form1.TrackBarMenuItem' does not contain a
definition for 'Value' and no extension method 'Value' accepting a
first argument of type 'goruntuIsleme2.Form1.TrackBarMenuItem' could
be found (are you missing a using directive or an assembly reference?)
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将内部 Trackbar 对象的值公开为新 TrackBarMenuItem 类的属性:
Expose the value of the internal Trackbar object as a property on your new TrackBarMenuItem class:
我正在添加我找到的解决方案。有人可能需要它:
如果您将其添加到代码中,您将能够通过设计器将轨迹栏添加为 ToolStripMenuItem。
i am adding the solution i found. someone might need it:
if you add this to your code, you will be able to add trackbars as ToolStripMenuItem via Designer.
您的类
TrackBarMenuItem
是否有一个名为Value
的属性?如果没有,您必须添加它。Does your class
TrackBarMenuItem
has a property calledValue
? If not, you have to add it.