我想使用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));
}
是的,您可以,因为当具有单个值时列表框的高度是21
,所以当添加新项目时,您可以为列表框的高添加21。
foreach (string FileName in oOpenDialog.FileNames)
{
lstbx_Box1.Height += 21;
lstbx_Box1.Items.Add(Path.GetFullPath(FileName));
}