问题
I am trying to make my treeview's checkboxes bigger. According to MSDN it says by default state images are capped at 16x16 and in order to use larger state images I need to specify this entry in the app.config file:
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
I tried adding this to my app.config and it did not change a thing, problem is the framework seems to actually shrink the images when I use 32x32 checkboxes.
Here is how I draw and set the checkboxes in my treeview's constructor:
public class MultiStateTreeView : TreeView
{
public MultiStateTreeView() : base()
{
ImageList ilStateImages = new ImageList();
ilStateImages.ImageSize = new Size(32, 32);
for (int i = 0; i <= 4; i++)
{
Bitmap bmpCheckBox = new Bitmap(32, 32);
Graphics gfxCheckBox = Graphics.FromImage(bmpCheckBox);
switch (i)
{
case 0: cbsState = CheckBoxState.UncheckedNormal; break;
case 1: cbsState = CheckBoxState.CheckedNormal; break;
case 2: cbsState = CheckBoxState.MixedNormal; break;
case 3: cbsState = CheckBoxState.UncheckedDisabled; break;
case 4: cbsState = CheckBoxState.UncheckedDisabled; break;
}
CheckBoxRenderer.DrawCheckBox(gfxCheckBox, new Point(2, 2), cbsState);
gfxCheckBox.Save();
ilStateImages.Images.Add(bmpCheckBox);
}
base.CheckBoxes = true;
this.StateImageList = ilStateImages;
}
}
Is there something that I am missing?
来源:https://stackoverflow.com/questions/37291184/drawing-large-checkboxes-for-treeview