Canducci.Forms.Mask
0.0.1
dotnet add package Canducci.Forms.Mask --version 0.0.1
NuGet\Install-Package Canducci.Forms.Mask -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Canducci.Forms.Mask" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Canducci.Forms.Mask" Version="0.0.1" />
<PackageReference Include="Canducci.Forms.Mask" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Canducci.Forms.Mask --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Canducci.Forms.Mask, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Canducci.Forms.Mask@0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Canducci.Forms.Mask&version=0.0.1
#tool nuget:?package=Canducci.Forms.Mask&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Canducci.Forms.Mask
Biblioteca mínima que fornece apenas MaskCurrency — um adaptador para aplicar máscara de moeda em um TextBox do Windows Forms.
O objetivo é ser pequeno, testável e seguro para uso em aplicações WinForms.
Principais APIs
- MaskCurrency (classe)
- MaskCurrency (extensão para TextBox)
Funcionalidades
- Formatação de moeda por cultura (padrão
pt-BR). - Eventos públicos para observar ou cancelar comportamento interno:
KeyPressCalled(KeyPressEventHandler) — pode cancelar definindoe.Handled = true.TextChangedCalled(EventHandler) — notificado antes do parse/format interno.LeaveCalled(EventHandler) — notificado após formatação quando o TextBox perde foco.ValueChanged(EventHandler) — quando o valor decimal muda.
Detach()/Dispose()para remover handlers e evitar leaks.
Exemplos
Anexar a máscara ao TextBox:
// attach mask using extension
var mask = myTextBox.MaskCurrency(0m, new CultureInfo("pt-BR"));
Cancelar o comportamento interno no KeyPress (exemplo):
mask.KeyPressCalled += (s, e) => {
if (e.KeyChar == '9')
{
e.Handled = true; // impede o processamento interno para essa tecla
}
};
Observar TextChanged:
mask.TextChangedCalled += (s, e) => {
var raw = myTextBox.Text; // texto antes do parse interno
};
Ação ao perder foco:
mask.LeaveCalled += (s, e) => {
// ação após a máscara formatar o texto
};
Liberar recursos:
mask.Detach();
mask.Dispose();
Notas
- A lógica de formatação está encapsulada em
CurrencyFormatterpara facilitar testes. - Esta biblioteca contém apenas
MaskCurrencypor design.
Contribuições e issues são bem-vindas.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. net10.0-windows7.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-windows7.0
- No dependencies.
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 110 | 8/3/2026 |