图片查看器的问题 [英] Problem with picture viewer

查看:76
本文介绍了图片查看器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请看一下。

我想打开一个文件夹然后在其中显示图像,并且还有下一个和上一个按钮。

>我在vb中的代码就像这样在vb中

Dim Filenames As List(Of String)=新列表(字符串)

Dim Counter As Integer = 0





Private Sub ShowButton_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理ShowButton.Click

如果FolderBrowserDialog1.ShowDialog()= DialogResult.OK然后

Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath," *。jpg"))

Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath," * .bmp"))

Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath,") ; *。png"))

如果Filenames.Count> 1然后PictureBox1.Load(文件名(计数器))

结束如果

结束子



来做同样的事情在C#我必须做什么?因为有一个错误..

解决方案

尝试:

 私人列表< string> Filenames =  new  List< string>(); 
private int 计数器= 0 ;
private void ShowButton_Click( object sender,EventArgs e)
{
if (FolderBrowserDialog1.ShowDialog()== DialogResult.OK)
{
Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, *。jpg));
Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, * .bmp) );
Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, *。png) );
if (Filenames.Count > = 1
PictureBox1.Load(文件名[Counter]);
}
}


问题只是转换成C#?您可以自动,在线或离线完成。请看我过去的答案:

代码解释,C#到VB.NET [ ^ ],

需要将vb代码转换为c# [ ^ ],

FixedPage to ContentPage转换c#代码进入vb.net [ ^ ]。



-S A

Please,take a look at this.
I want to open a folder and then display the images in it and also have buttons next and previous.
>My code in vb was like this in vb
Dim Filenames As List(Of String) = New List(Of String)
Dim Counter As Integer = 0


Private Sub ShowButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowButton.Click
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.jpg"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.bmp"))
Filenames.AddRange(System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.png"))
If Filenames.Count > 1 Then PictureBox1.Load(Filenames(Counter))
End If
End Sub

to do the same thing in C# I have to do what?Because there's an error..

解决方案

Try:

private List<string> Filenames = new List<string>();
private int Counter = 0;
private void ShowButton_Click(object sender, EventArgs e)
    {
    if (FolderBrowserDialog1.ShowDialog() == DialogResult.OK)
        {
        Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.jpg"));
        Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.bmp"));
        Filenames.AddRange(Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.png"));
        if (Filenames.Count >= 1)
            PictureBox1.Load(Filenames[Counter]);
        }
    }


It the problem just translation into C#? You can do it automatically, online or off-line. Please see my past answers:
Code Interpretation, C# to VB.NET[^],
Need to convert vb code to c#[^],
FixedPage to ContentPage convert c# code into vb.net[^].

—SA


这篇关于图片查看器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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