如何将trackBar控件放置到特定位置(在程序中计算). [英] How to position a trackBar control to a specific position ( calculated in the program).

查看:188
本文介绍了如何将trackBar控件放置到特定位置(在程序中计算).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我使用轨迹栏从图像列表中选择某个图像.
到目前为止,这个工作正常.但是由于图像很多,仅通过滚动就不可能获得正确的图像尺寸.灵敏度太差.
在pictureBox中,我使用轨迹栏值作为索引显示选定的图像,以从图像列表中获取图像文件的路径.

为了进行微调,我添加了加号1 减号1 按钮,以逐一遍历列表条目.

但是现在我有一个问题,我希望轨迹栏显示调整后的位置.

问题:有可能吗?我没有找到一种方法或一个属性来调整跟踪栏的位置. 值仅提供您的实际值,但不会改变标准.而 TabIndex 的内容对我来说还不清楚.
在下面的简短示例中注释掉的行都不会产生预期的 红色效果.

Hello,

I use a trackbar to select a certain image out of a list of images.
This works fine so far. But as there are many images it is impossible to get the correct immage just by scrolling. The sensitivity is too poor.
In a pictureBox I show the selected image using the trackbar value as index to get the path to the image file from the list of images.

To do the fine adjustment I added a Plus 1 and a Minus 1 button to step one by one through the list entries.

But now I have a problem, I want the trackbar to show the adjusted position.

Question: is that possible. I have not found a method nor a property that adjusts teh trackbar position. Value just gives you the actual value but does not change the bar. And what TabIndex does ist not clear to me.
The lines commented out in the short example below both do not yield the desired effect.

private void btnEM1_Click(object sender, EventArgs e)
{
    actEnd = actEnd - 1;
    if ((actEnd < numberFiles) && (actEnd > -1))
    {
        txtBxStartFrame.Text = fileListS[actEnd];
        showFrame(actEnd, true);
    }
    else
    {
        actEnd = 0;
    }
    // trackBarEnd.TabIndex = actEnd;   this does not work
    // trackBarEnd.Value = actEnd;    and this does not work either.
}





提前非常感谢您提供任何提示.





Many thanks in advance for any hint.

推荐答案

尝试以下操作:

Try this:

trackBarEnd.Value = actEnd;
trackBarEnd.Update();


很好的TabIndex永远不会帮助您-查看MSDN:MSDN选项卡索引-选项卡索引是用户使用Tab键在表单上跳转时选择控件的顺序.至于Value,它应该将TrackBar(假设您是指ScrollBar控件?)更改为所需位置.每当我使用它时,我都没有发现任何问题.但是,您是否考虑过使用ListView它将图像显示为列表项-比尝试自己编写并拥有所需的一切要好得多.此页面可能会帮助您: MSDN-关于列表视图控制 [ ^ ]

希望这会有所帮助,
Ed
Well TabIndex will never help you - look at MSDN: MSDN Tab Index - Tab index is what order controls are selected in when the user uses the tab key to jump through controls on your form. As for Value, it should change the TrackBar (assuming you mean ScrollBar control?) to the desired position. I have not found a problem with this whenever I have used it. However, have you considered using a ListView which will display images as list items - it is far better than trying to write your own and has everything that you want. This page may help you out: MSDN - About the List View Control[^]

Hope this helps,
Ed


这篇关于如何将trackBar控件放置到特定位置(在程序中计算).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆