====== ToolStrip上のアイテムを引き延ばす ====== ブラウザのアドレスバーの様に1つのアイテムをその幅いっぱいまで引き伸ばすコードです。あんまり深く検証してませんので、実際使うときはよく確かめてから使ってください。 void stretchToolItem(ToolStrip^ bar, ToolStripItem^ itemstretch) { int all = bar->Size.Width; int other = 0; other += bar->Margin.Left; other += bar->Margin.Right; other += bar->GripRectangle.Width; other += bar->GripMargin.Left + bar->GripMargin.Right; for each( ToolStripItem^ item in bar->Items ) { if ( item != itemstretch ) { other += item->Size.Width; other += (item->Margin.Left + item->Margin.Right); other += (item->Padding.Left + item->Padding.Right); } } itemstretch->Size = ::Size(all - other, itemstretch->Size.Height); itemstretch->Visible = false; itemstretch->Visible = true; } barがToolStripでitemstretchが引き延ばすアイテムです。最後にVisibleを設定し直してますが、なぜか引き延ばしたアイテムが表示されなくなるときがあるので付けています。