Skip to content

Commit 54ae03b

Browse files
committed
fixed column height for high dpi, added checklist custom font, updated version
1 parent 78c1d32 commit 54ae03b

File tree

6 files changed

+39
-22
lines changed

6 files changed

+39
-22
lines changed

AdvancedDataGridView/AdvancedDataGridView.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -786,21 +786,21 @@ public void TriggerSortStringChanged()
786786
}
787787
//sort datasource
788788
if (sortEventArgs.Cancel == false)
789-
{
790-
if (this.DataSource is BindingSource bindingsource)
791-
{
792-
bindingsource.Sort = sortEventArgs.SortString;
793-
}
794-
else if (this.DataSource is DataView dataview)
795-
{
796-
dataview.Sort = sortEventArgs.SortString;
797-
}
798-
else if (this.DataSource is DataTable datatable)
799-
{
800-
if (datatable.DefaultView != null)
801-
datatable.DefaultView.Sort = sortEventArgs.SortString;
802-
}
803-
}
789+
{
790+
if (this.DataSource is BindingSource bindingsource)
791+
{
792+
bindingsource.Sort = sortEventArgs.SortString;
793+
}
794+
else if (this.DataSource is DataView dataview)
795+
{
796+
dataview.Sort = sortEventArgs.SortString;
797+
}
798+
else if (this.DataSource is DataTable datatable)
799+
{
800+
if (datatable.DefaultView != null)
801+
datatable.DefaultView.Sort = sortEventArgs.SortString;
802+
}
803+
}
804804
//invoke SortStringChanged
805805
if (!_sortStringChangedInvokeBeforeDatasourceUpdate)
806806
{
@@ -1423,7 +1423,7 @@ private void Cell_FilterPopup(object sender, ColumnHeaderCellEventArgs e)
14231423
if (_filterOrderList.Count() > 0 && _filterOrderList.Last() == column.Name)
14241424
filterMenu.Show(this, rect.Left, rect.Bottom, true);
14251425
else
1426-
filterMenu.Show(this, rect.Left, rect.Bottom, MenuStrip.GetValuesForFilter(this, column.Name));
1426+
filterMenu.Show(this, rect.Left, rect.Bottom, column.Name);
14271427
}
14281428
}
14291429
}
0 Bytes
Binary file not shown.

AdvancedDataGridView/ColumnHeaderCell.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public ColumnHeaderCell(DataGridViewColumnHeaderCell oldCell, bool filterEnabled
7575
Style = oldCell.Style;
7676
_filterEnabled = filterEnabled;
7777

78+
_filterButtonImageSize = new Size((int)Math.Round(oldCell.Size.Height * 0.8), (int)Math.Round(oldCell.Size.Height * 0.8));
79+
7880
ColumnHeaderCell oldCellt = oldCell as ColumnHeaderCell;
7981
if (oldCellt != null && oldCellt.MenuStrip != null)
8082
{
@@ -653,7 +655,7 @@ private Rectangle GetFilterBounds(bool withOffset = true)
653655

654656
Point p = new Point(
655657
(withOffset ? cell.Right : cell.Width) - _filterButtonImageSize.Width - _filterButtonMargin.Right,
656-
(withOffset ? cell.Bottom : cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom);
658+
(withOffset ? cell.Bottom + 2 : cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom);
657659

658660
return new Rectangle(p, _filterButtonImageSize);
659661
}

AdvancedDataGridView/MenuStrip.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,21 +511,27 @@ public void SetLoadedMode(bool enabled)
511511
/// <param name="control"></param>
512512
/// <param name="x"></param>
513513
/// <param name="y"></param>
514-
/// <param name="vals"></param>
515-
public void Show(Control control, int x, int y, IEnumerable<DataGridViewCell> vals)
514+
/// <param name="columnName"></param>
515+
public void Show(Control control, int x, int y, string columnName)
516516
{
517517
_removedNodes = new TreeNodeItemSelector[] { };
518518
_removedsessionNodes = new TreeNodeItemSelector[] { };
519519

520520
//add nodes
521-
BuildNodes(vals);
521+
DataGridView dataGridView = control as DataGridView;
522+
IEnumerable<DataGridViewCell> vals = dataGridView != null ? GetValuesForFilter(dataGridView, columnName) : Enumerable.Empty<DataGridViewCell>();
523+
BuildNodes(vals, dataGridView, columnName);
522524
//set the starting nodes
523525
_startingNodes = DuplicateNodes(_loadedNodes);
524526

525527
if (_activeFilterType == FilterType.Custom)
526528
SetNodesCheckState(_loadedNodes, false);
527529
base.Show(control, x, y);
528530

531+
//force checklist refresh
532+
checkList.BeginUpdate();
533+
checkList.EndUpdate();
534+
529535
_filterclick = false;
530536

531537
_checkTextFilterChangedEnabled = false;
@@ -927,7 +933,9 @@ private static string FormatFilterString(string text)
927933
/// Add nodes to checkList
928934
/// </summary>
929935
/// <param name="vals"></param>
930-
private void BuildNodes(IEnumerable<DataGridViewCell> vals)
936+
/// <param name="dataGridView"></param>
937+
/// <param name="columnName"></param>
938+
private void BuildNodes(IEnumerable<DataGridViewCell> vals, DataGridView dataGridView, string columnName)
931939
{
932940
if (!IsFilterChecklistEnabled)
933941
return;
@@ -1105,9 +1113,16 @@ orderby cs.Key ascending
11051113
//add string nodes
11061114
else
11071115
{
1116+
//get custom font by columnName
1117+
Font nodeFont = null;
1118+
if (dataGridView != null && !String.IsNullOrEmpty(columnName))
1119+
nodeFont = dataGridView.Columns[columnName].DefaultCellStyle.Font;
1120+
11081121
foreach (var v in nonulls.GroupBy(c => c.Value).OrderBy(g => g.Key))
11091122
{
11101123
TreeNodeItemSelector node = TreeNodeItemSelector.CreateNode(v.First().FormattedValue.ToString(), v.Key, CheckState.Checked, TreeNodeItemSelector.CustomNodeType.Default);
1124+
if (nodeFont != null)
1125+
node.NodeFont = nodeFont;
11111126
ChecklistAddNode(node);
11121127
}
11131128
}
0 Bytes
Binary file not shown.

_DevTools/AutoBuilder.config.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $solutionName = "AdvancedDataGridView"
66
$versionMajor = "1"
77
$versionMinor = "2"
88
$versionBuild = GetVersionBuild
9-
$versionRevision = "11"
9+
$versionRevision = "12"
1010
#build version number
1111
$version = GetVersion $versionMajor $versionMinor $versionBuild $versionRevision
1212

0 commit comments

Comments
 (0)