Giter Site home page Giter Site logo

Comments (11)

ShammyLevva avatar ShammyLevva commented on June 14, 2024 1

I've had a play around and it seems that it's a simple fix. Within the ColumnHeaderCell constructor we can deal with sizes over 16 pixels by setting the _filterButtonImageSize larger when a larger font/scaling is used. Adding the following to the constructor fixes the issue.

if(oldCell.Size.Height > 32) _filterButtonImageSize = new Size(oldCell.Size.Height/2, oldCell.Size.Height/2);

This check makes sure it's no smaller than 16x16 and retains the discreet apearance of a drop down arrow in the corner even when scaled on rows with large fonts that are some 48px.

For my app which deals with family history and thus the user base skews older they tend to want larger fonts and higher screen resolutions so I've examples where they have the scaling at 300% and fonts bumped up to 48px and so a cell height of over 100px a fixed 16x16 icon looks tiny when the cell height is 100px hence need for scaling.

If you'd be so kind as to apply this simple one liner fix to the main body of the code it would be appreciated and save me having to use a forked version.

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024 1

Thanks for helps. That makes sense, the font percentage behaviour I mean.
I'm can not test it for a few days. It will be a pleasure to apply this fix to the master branch and then release a new version.

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

Hello,

Have you try to set the AutoScaleMode to Dpi?
Can you try to run the AdvancedDataGridViewSample project, if you look at the Program.cs file there you can find a simple Dpi setting mode.

from advanceddatagridview.

ShammyLevva avatar ShammyLevva commented on June 14, 2024

I tried this but got nowhere. I've had a user report the same issue and I'm fairly sure his machine isn't a high DPI machine so I think I was wrong thinking it was that. I think it's the fixed 16x16 size that appears to be used.

from advanceddatagridview.

ShammyLevva avatar ShammyLevva commented on June 14, 2024

It would appear that it has same issue when used on regular screens where the scaling is high or the font is set large. The button isn't scaling to the font used, it appears to be 16x16 regardless of size of columnheader font. It looks like the aim was to make it similar to Excel in which case perhaps the simplest solution is to set the size of the icon to match the height of the columnheadercell.

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

Hello @ShammyLevva,
seems to work your mod but I prefer to do it on percentage, so try this one if it fits for you too:

In ColumnHeaderCell constructor ColumnHeaderCell
after _filterEnabled = filterEnabled; add
_filterButtonImageSize = new Size((int)Math.Round(oldCell.Size.Height * 0.8), (int)Math.Round(oldCell.Size.Height * 0.8));

In ColumnHeaderCell method GetFilterBounds
replace (withOffset ? cell.Bottom: cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom); with
(withOffset ? cell.Bottom + 2 : cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom);

from advanceddatagridview.

ShammyLevva avatar ShammyLevva commented on June 14, 2024

Looks good. It is worth testing on an unusual edge case though. If the column header is allowed to wrap text and goes to a 2nd line ie: the cell height is double the normal height as it has 2 lines of text. In that case the button looks unusually big. So it might be better using a percentage of the font height rather than the cell height. Perhaps even 100% of the font height given that the font height will be smaller than the cell height and thus close to your chosen 80%?

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

I get what you mean, let me find some spare time to work on it... maybe next days. I'll keep you updated.

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

I finally had time to check it. Let me know if it works to you.

In ColumnHeaderCell constructor ColumnHeaderCell
after _filterEnabled = filterEnabled; add

            float fontHeight = 23;
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                fontHeight = g.MeasureString("O", oldCell.DataGridView.Font).Height;
            }
            _filterButtonImageSize = new Size((int)(fontHeight * 1.3), (int)(fontHeight * 1.3));

In ColumnHeaderCell method GetFilterBounds
replace (withOffset ? cell.Bottom: cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom); with
(withOffset ? cell.Bottom : cell.Height) / 2 - _filterButtonImageSize.Height / 2);

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

Have you check it?

from advanceddatagridview.

davidegironi avatar davidegironi commented on June 14, 2024

Published in version 1.2.x.12

from advanceddatagridview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.