0

我想使用 OpenDialog 选择多个文件并将它们显示在列表框中。如果我的文件路径多于列表框,我希望列表框自动垂直增长以适合所有文件名。

请问这个怎么做?谢谢您的帮助。

foreach (string FileName in oOpenDialog.FileNames)
{
   //lstbx_Box1.IntegralHeight = false;  //This doesn't auto-grow the list box.
   lstbx_Box1.Items.Add(Path.GetFullPath(FileName));
}
                   
4

1 回答 1

1

是的,您可以,因为当列表框的高度只有一个值时,21您可以在添加新项目时为列表框的高度添加 21。

foreach (string FileName in oOpenDialog.FileNames)
{
   lstbx_Box1.Height += 21;
   lstbx_Box1.Items.Add(Path.GetFullPath(FileName));
}
于 2021-06-08T13:53:03.697 回答