mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added auto size drop down extension for combo box
This commit is contained in:
parent
6601b36932
commit
7f88c8c75f
4 changed files with 18 additions and 2 deletions
|
@ -73,6 +73,7 @@ public void Add(object item)
|
|||
public void AddRange(object[] items)
|
||||
{
|
||||
cbList.Items.AddRange(items);
|
||||
cbList.AutoSizeDropDown();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -680,6 +680,21 @@ public static void RefreshItems(this ComboBox cb)
|
|||
typeof(ComboBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, cb, new object[] { });
|
||||
}
|
||||
|
||||
public static void AutoSizeDropDown(this ComboBox cb)
|
||||
{
|
||||
int maxWidth = 0;
|
||||
int verticalScrollBarWidth = cb.Items.Count > cb.MaxDropDownItems ? SystemInformation.VerticalScrollBarWidth : 0;
|
||||
foreach (object item in cb.Items)
|
||||
{
|
||||
int tempWidth = TextRenderer.MeasureText(cb.GetItemText(item), cb.Font).Width + verticalScrollBarWidth;
|
||||
if (tempWidth > maxWidth)
|
||||
{
|
||||
maxWidth = tempWidth;
|
||||
}
|
||||
}
|
||||
cb.DropDownWidth = maxWidth;
|
||||
}
|
||||
|
||||
public static void RefreshItem(this ListBox lb, int index)
|
||||
{
|
||||
typeof(ListBox).InvokeMember("RefreshItem", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, lb, new object[] { index });
|
||||
|
|
|
@ -1894,7 +1894,7 @@ internal static string ShapeManager_CreateToolbar_StartingStepValue {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use type:.
|
||||
/// Looks up a localized string similar to Step type:.
|
||||
/// </summary>
|
||||
internal static string ShapeManager_CreateToolbar_StepType {
|
||||
get {
|
||||
|
|
|
@ -738,6 +738,6 @@ X: {4} Y: {5}</value>
|
|||
<value>Menu icon size:</value>
|
||||
</data>
|
||||
<data name="ShapeManager_CreateToolbar_StepType" xml:space="preserve">
|
||||
<value>Use type:</value>
|
||||
<value>Step type:</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in a new issue