Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make longer preset names still fully visible in the preset combobox #13

Closed
Premo36 opened this issue Feb 1, 2022 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@Premo36
Copy link
Owner

Premo36 commented Feb 1, 2022

Implement something like this code (taken from https://stackoverflow.com/questions/48573024/add-scrollbar-to-winforms-combobox/48573154) to make the preset list as large as the longest preset name so it's always visible.

ComboBox senderComboBox = (ComboBox)sender;
int width = senderComboBox.DropDownWidth;
Graphics g = senderComboBox.CreateGraphics();
Font font = senderComboBox.Font;
int vertScrollBarWidth =
    (senderComboBox.Items.Count > senderComboBox.MaxDropDownItems)
    ? SystemInformation.VerticalScrollBarWidth : 0;

int newWidth;
foreach (string s in ((ComboBox)sender).Items)
{
    newWidth = (int)g.MeasureString(s, font).Width
        + vertScrollBarWidth;
    if (width < newWidth)
    {
        width = newWidth;
    }
}
senderComboBox.DropDownWidth = width;
@Premo36 Premo36 added the enhancement New feature or request label Feb 1, 2022
@Premo36 Premo36 self-assigned this Feb 1, 2022
@Premo36 Premo36 closed this as completed in 354616f Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant