[C#]如何在列表框中向下滚动。 [英] [C#]how do I scroll down on listbox.

查看:83
本文介绍了[C#]如何在列表框中向下滚动。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。我在表单中制作了列表框

2.但我想扩大滚动条的宽度。因此,使用工具箱中的VScroll栏自定义新的滚动条

3.但我不知道将Combine VScroll Bar与列表框结合使用,如何向下滚动列表框我是... 。

4.我认为..使用事件.Scroll + = new System.Windows.Forms.ScrollEventHandler但我不知道如何具体方法...



  private   void  frmSettingConfig_Load(  object  sender,EventArgs e)
{
this .LoadSettingConfig();
this .EnableVScrollBar();
}

private void LoadSettingConfig()
{
try
{
LogWrite.Log.InformationWrite( 加载设置配置。);
string filepath = Application.StartupPath;

if (Directory.Exists(filepath)== true
{
DirectoryInfo di = new DirectoryInfo(filepath);

foreach (FileInfo item in di.GetFiles())
{
if (item.Name.Contains( SettingConfig))
{
mSettingConfigList.Add(item.Name);
}
}
}
else
{
MessageBox.Show( 不存在目录中的配置文件
);
}
this .ShowSettingConfig();
}
catch (Exception ex)
{
MessageBox.Show( 加载设置配置错误!);
LogWrite.Log.InformationWrite( 加载设置配置错误 +
ex的ToString());
}

}

private void EnableVScrollBar()
{
VScrollBar vScroller = new VScrollBar();

this .lbxSettingConfigList.Controls.Add(vScroller);
vScroller.Height = lbxSettingConfigList.Height;
vScroller.Width = 30 ;
vScroller.Dock = DockStyle.Right;

vScroller.Scroll + = new
System.Windows.Forms.ScrollEventHandler(vScoller_Scroll);
}

private void vScoller_Scroll( object sender,ScrollEventArgs e)
{
// 我如何能 ?在这个街区。
}





我尝试了什么:



eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...查询方案


请查看此链接。在问题本身用户已经尝试实现它。


1. I was made List box in form
2. but I wanna enlarge width of Scroll Bar. So, Customize a new Scroll Bar using VScroll bar in 'Tool Box'
3. but I don't know Combine VScroll Bar with List box and How do I scroll down List box I was made...
4. I think.. Using Event " .Scroll += new System.Windows.Forms.ScrollEventHandler" but I don't know how to specific method...

private void frmSettingConfig_Load(object sender, EventArgs e)
{
    this.LoadSettingConfig();
    this.EnableVScrollBar();
}

private void LoadSettingConfig()
{
    try
    {
        LogWrite.Log.InformationWrite("Load Setting Config.");
        string filepath = Application.StartupPath;

        if (Directory.Exists(filepath) == true)
        {
            DirectoryInfo di = new DirectoryInfo(filepath);

            foreach (FileInfo item in di.GetFiles())
            {
                if (item.Name.Contains("SettingConfig"))
                {
                    mSettingConfigList.Add(item.Name);
                }
            }
        }
        else
        {
            MessageBox.Show("Does not Exist Setting Config File in Directory
            !");
        }
        this.ShowSettingConfig();
    }
    catch (Exception ex)
    {
        MessageBox.Show("Load Setting Config Error !");
        LogWrite.Log.InformationWrite("Load Setting Config Error" +
        ex.ToString());
    }

}

private void EnableVScrollBar()
{
    VScrollBar vScroller = new VScrollBar();

    this.lbxSettingConfigList.Controls.Add(vScroller);
    vScroller.Height = lbxSettingConfigList.Height;
    vScroller.Width = 30;
    vScroller.Dock = DockStyle.Right;

    vScroller.Scroll += new
    System.Windows.Forms.ScrollEventHandler(vScoller_Scroll);
}

private void vScoller_Scroll(object sender, ScrollEventArgs e)
{
    // How do I ? in this block.
}



What I have tried:

eeeeeeeeeeeeeeeeeeeeeeeeeeeeevrything..

解决方案

Hi, please try changing the scroll viewer in the control template of Listbox.
please check this Link. In the question itself user has tried implementing that.


这篇关于[C#]如何在列表框中向下滚动。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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