Skip to content

Commit

Permalink
Bugfixes for 2.0.0
Browse files Browse the repository at this point in the history
The main difference for this is the change of ContextMenu to ContextMenuStrip. The header context menu now is opened also when clicking on any cell in the table.
If this is not desired table.ContextMenuStrip should be set to null

- Moved gitversion.yml
- Include pdbs in nuget package
- create symbol package
- Fixed nullref exception in HeaderContextMenu OnOpening in case the model is not set
- Avoid duplictate header columns in header context menu
  • Loading branch information
schoetbi committed Apr 30, 2024
1 parent 1ec40aa commit 97f4bf5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
2 changes: 2 additions & 0 deletions gitversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
next-version: 2.0.0
mode: ContinuousDeployment
47 changes: 29 additions & 18 deletions src/XPTable/Models/HeaderContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

namespace XPTable.Models
{
using System.Data.Common;
using System.Linq;

/// <summary>
/// A specialized ContextMenu for Column Headers
/// </summary>
Expand Down Expand Up @@ -150,27 +153,34 @@ internal bool Enabled

protected override void OnOpening(CancelEventArgs e)
{
if (model.Columns.Count > 0)
if (Items.Count == 0 && model?.Columns != null)
{
ToolStripMenuItem item;

for (var i = 0; i < model.Columns.Count; i++)
foreach (var column in model.Columns.OfType<Column>().Take(9))
{
if (i == 10)
var item = new ToolStripMenuItem(column.Text)
{
Items.Add(separator);
Items.Add(moreMenuItem);

break;
}

// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
item = new ToolStripMenuItem(model.Columns[i].Text);
Tag = column
};
item.Click += menuItem_Click;
item.Checked = model.Columns[i].Visible;

item.Checked = column.Visible;
Items.Add(item);
}

if (model.Columns.Count > 9)
{
Items.Add(separator);
Items.Add(moreMenuItem);
}
}
else
{
foreach (var item in Items.OfType<ToolStripMenuItem>())
{
if (item.Tag is Column column)
{
item.Checked = column.Visible;
}
}
}

base.OnOpening(e);
Expand All @@ -184,11 +194,12 @@ protected override void OnOpening(CancelEventArgs e)
private void menuItem_Click(object sender, EventArgs e)
{
var item = (ToolStripMenuItem)sender;

model.Columns[item.MergeIndex].Visible = !item.Checked;
if (item.Tag is Column column)
{
column.Visible = !item.Checked;
}
}


/// <summary>
///
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/XPTable/Models/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ public Table()
beginUpdateCount = 0;
init = false;
preview = false;
ContextMenuStrip = headerContextMenu;
}
#endregion

Expand Down
5 changes: 4 additions & 1 deletion src/XPTable/XPTable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<SignAssembly>true</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseFullSemVerForNuGet>true</UseFullSemVerForNuGet>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -81,7 +82,7 @@
<ItemGroup>
<Content Include="Resources\XPTable32x32.png" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -92,6 +93,8 @@
<Reference Include="System.Design" />
</ItemGroup>
<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<AssemblyTitle>XPTable</AssemblyTitle>
<Description>A fully customizable ListView style control based on Java's JTable</Description>
<Company></Company>
Expand Down
1 change: 0 additions & 1 deletion src/XPTable/gitversion.yml

This file was deleted.

0 comments on commit 97f4bf5

Please sign in to comment.