ToolStripItemImageScaling Перечисление
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Указывает, настраивается ли размер изображения на ToolStripItem автоматически в соответствии с ToolStrip при сохранении исходных пропорций изображения.
public enum class ToolStripItemImageScaling
public enum ToolStripItemImageScaling
type ToolStripItemImageScaling =
Public Enum ToolStripItemImageScaling
- Наследование
Поля
| Имя | Значение | Описание |
|---|---|---|
| None | 0 | Указывает, что размер изображения на объекте ToolStripItem не настраивается автоматически, чтобы он соответствовал ToolStrip. |
| SizeToFit | 1 | Указывает, что размер изображения на объекте ToolStripItem автоматически настраивается для соответствия ToolStrip. |
Примеры
Следующий пример задает ToolStripItem.ImageScaling для SizeToFitсвойства значение .
ToolStripButton^ imageButton;
void InitializeImageButtonWithToolTip()
{
// Construct the button and set the image-related properties.
imageButton = gcnew ToolStripButton;
imageButton->Image =
gcnew Bitmap(Timer::typeid,"Timer.bmp");
imageButton->ImageScaling =
ToolStripItemImageScaling::SizeToFit;
// Set the background color of the image to be transparent.
imageButton->ImageTransparentColor =
Color::FromArgb(0, 255, 0);
// Show ToolTip text, set custom ToolTip text, and turn
// off the automatic ToolTips.
toolStrip1->ShowItemToolTips = true;
imageButton->ToolTipText = "Click for the current time";
imageButton->AutoToolTip = false;
// Add the button to the ToolStrip.
toolStrip1->Items->Add(imageButton);
}
// internal:
internal ToolStripButton imageButton;
private void InitializeImageButtonWithToolTip()
{
// Construct the button and set the image-related properties.
imageButton = new ToolStripButton();
imageButton.Image = new Bitmap(typeof(Timer), "Timer.bmp");
imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit;
// Set the background color of the image to be transparent.
imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0);
// Show ToolTip text, set custom ToolTip text, and turn
// off the automatic ToolTips.
toolStrip1.ShowItemToolTips = true;
imageButton.ToolTipText = "Click for the current time";
imageButton.AutoToolTip = false;
// Add the button to the ToolStrip.
toolStrip1.Items.Add(imageButton);
}
Friend WithEvents imageButton As ToolStripButton
Private Sub InitializeImageButtonWithToolTip()
' Construct the button and set the image-related properties.
imageButton = New ToolStripButton()
imageButton.Image = New Bitmap(GetType(Timer), "Timer.bmp")
imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit
' Set the background color of the image to be transparent.
imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0)
' Show ToolTip text, set custom ToolTip text, and turn
' off the automatic ToolTips.
toolStrip1.ShowItemToolTips = True
imageButton.ToolTipText = "Click for the current time"
imageButton.AutoToolTip = False
' Add the button to the ToolStrip.
toolStrip1.Items.Add(imageButton)
End Sub
Комментарии
Свойства Image, и ImageIndexImageAlignImageKeyImageScaling свойства относятся к различным аспектам обработки изображений. Используйте изображения в ToolStrip элементах управления, задав эти свойства напрямую или задав свойство только ImageList во время выполнения.
Масштабирование изображений определяется взаимодействием свойств в обоих ToolStrip и ToolStripItemследующим образом:
ImageScalingSize — это масштаб окончательного изображения, определяемого сочетанием параметра образа ImageScaling и параметра контейнера AutoSize .
Если AutoSize значение равно
true(по умолчанию) иToolStripItemImageScalingSizeToFitне выполняется масштабирование изображений, а ToolStrip размер является самым большим элементом или заданным минимальным размером.Если AutoSize и
ToolStripItemImageScalingестьfalseNone, ни изображение, ToolStrip ни масштабирование не происходит.
Чтобы управлять размером изображения, используйте ImageScalingSize свойство.