1
ディレクトリにあるフォルダを表すtoolstripdropdownbuttonsを含むツールストリップがあります。私は、各toolstripdropdownボタンのドロップダウンメニューから、見つかったサブフォルダを選択したいと思います。ドロップダウンメニュー(C#Winforms)を含むツールストリップにToolstripDropDownButtonをプログラムで追加する方法
private void populateLinks()
{
linksToolStrip.Items.Clear();
DirectoryInfo linksFolder = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Favorites) + "\\Links");
foreach (DirectoryInfo linksDirectory in linksFolder.GetDirectories())
{
Image favImage = Properties.Resources.Folder;
ToolStripDropDownButton button = new ToolStripDropDownButton();
button.Text = Truncate(linksDirectory.Name, 22);
button.ToolTipText = linksDirectory.Name + "\nDate Created: " + Directory.GetCreationTime(linksDirectory.FullName);
button.Image = favImage;
button.Tag = linksDirectory.FullName;
linksToolStrip.Items.Add(button);
populateLinksFolders(linksDirectory, button.DropDown);
}
:この例は
Links Bar Example
(写真参照)私が試してみましたコードを、私は次のコードを試してみましたが、私はそれについて移動する方法が非常にわからないInternet Explorerのリンクバーになります
および
private void populateLinksFolders(DirectoryInfo subdirectory, ToolStripDropDown tsdd)
{
foreach (DirectoryInfo directory in subdirectory.GetDirectories())
{
populateLinksFolders(directory, ?) //<- Everything tried here fails
}
}
どうすればこの問題を解決できますか?
おかげで、これは私のqueston – LordPerun
に答え興味深い問題は、ドロップダウンメニューが小さすぎる場所について来て、自動サイズへの道それか、この問題を修正はありますか? – LordPerun
これがあなたの質問に答えるなら、答えの横にあるチェックマークを使うことを検討してください。デフォルトではボタンのサイズは自動的に変更されますが、そうでない場合は 'button.AutoSize = true;'を追加することができます。 – endofzero