Skip to content

Commit a70273e

Browse files
committed
Readme for repository added
1 parent d8fea77 commit a70273e

File tree

9 files changed

+426
-0
lines changed

9 files changed

+426
-0
lines changed

Questions.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeleteTextbox", "DeleteText
66
EndProject
77
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeclareTextBoxValue", "DeclareTextBoxValue\DeclareTextBoxValue.csproj", "{FE2FF500-B2BA-4C12-87ED-C6AA98188A8B}"
88
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextBoxMaskInput", "TextBoxMaskInput\TextBoxMaskInput.csproj", "{D07889BA-56B3-48C4-9434-9D6B56EA7A28}"
10+
EndProject
911
Global
1012
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1113
Debug|Any CPU = Debug|Any CPU
@@ -20,5 +22,9 @@ Global
2022
{FE2FF500-B2BA-4C12-87ED-C6AA98188A8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2123
{FE2FF500-B2BA-4C12-87ED-C6AA98188A8B}.Release|Any CPU.Build.0 = Release|Any CPU
2224
{FE2FF500-B2BA-4C12-87ED-C6AA98188A8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{D07889BA-56B3-48C4-9434-9D6B56EA7A28}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{D07889BA-56B3-48C4-9434-9D6B56EA7A28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{D07889BA-56B3-48C4-9434-9D6B56EA7A28}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{D07889BA-56B3-48C4-9434-9D6B56EA7A28}.Release|Any CPU.ActiveCfg = Release|Any CPU
2329
EndGlobalSection
2430
EndGlobal

README.textile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
h1. Basic Examples for C# Windows Forms Questions on Stackoverflow
2+
3+
This repository may be of use for the abosolute newbie in C# and Windows Forms
4+
5+

TextBoxMaskInput/MainForm.Designer.cs

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TextBoxMaskInput/MainForm.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Abe
4+
* Date: 04.05.2013
5+
* Time: 14:36
6+
*
7+
* To change this template use Tools | Options | Coding | Edit Standard Headers.
8+
*/
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Drawing;
12+
using System.Windows.Forms;
13+
14+
namespace TextBoxMaskInput
15+
{
16+
/// <summary>
17+
/// Dynamic mask textbox money Input
18+
/// http://stackoverflow.com/questions/15989717/
19+
/// </summary>
20+
public partial class MainForm : Form
21+
{
22+
public MainForm()
23+
{
24+
//
25+
// The InitializeComponent() call is required for Windows Forms designer support.
26+
//
27+
InitializeComponent();
28+
29+
}
30+
31+
//this only allow numbers and "." and "," on textimbox imput
32+
private void Textbox_KeyPressEvent(object sender, KeyPressEventArgs e)
33+
{
34+
// TODO: difference in cultures regarding decimal seperator "." vs. ","
35+
// us 1,000.20 onethousand and 20 cent
36+
// eu 1.000,20 onethousand and 20 cent
37+
var keyChar = e.KeyChar;
38+
var tbText = (sender as TextBox).Text;
39+
if (!char.IsControl(keyChar)
40+
&& !char.IsDigit(keyChar)
41+
&& keyChar != '.' && keyChar != ',')
42+
{
43+
e.Handled = true;
44+
}
45+
46+
// only allow one decimal point
47+
if (keyChar == '.' && tbText.IndexOf('.') > -1)
48+
{
49+
e.Handled = true;
50+
}
51+
if(keyChar == ',' && tbText.IndexOf(',') > -1){
52+
e.Handled = true;
53+
}
54+
}// Textbox_KeyPressEvent
55+
56+
private void TextBox_LeaveEvent(object sender, EventArgs e)
57+
{
58+
var tb = sender as TextBox;
59+
var tbText = tb.Text;
60+
if(tbText.IndexOf(" ") !=-1){
61+
var tbText2 = tbText.Substring(0, tbText.IndexOf(" ")-1);
62+
var temp = String.Format("{0:D0}", tbText2);
63+
MessageBox.Show("temp: _" + temp + "_");
64+
65+
}
66+
if(tbText.Length>0 && tbText.IndexOf(" ") == -1){
67+
decimal cubic = Convert.ToDecimal(tbText);
68+
tb.Text = string.Format("{0:c}", Convert.ToDecimal(cubic));
69+
label1.Text = tb.Text;
70+
}
71+
}
72+
73+
}// end of class
74+
}

TextBoxMaskInput/MainForm.resx

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
</root>

TextBoxMaskInput/Program.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Abe
4+
* Date: 04.05.2013
5+
* Time: 14:36
6+
*
7+
* To change this template use Tools | Options | Coding | Edit Standard Headers.
8+
*/
9+
using System;
10+
using System.Windows.Forms;
11+
12+
namespace TextBoxMaskInput
13+
{
14+
/// <summary>
15+
/// Class with program entry point.
16+
/// </summary>
17+
internal sealed class Program
18+
{
19+
/// <summary>
20+
/// Program entry point.
21+
/// </summary>
22+
[STAThread]
23+
private static void Main(string[] args)
24+
{
25+
Application.EnableVisualStyles();
26+
Application.SetCompatibleTextRenderingDefault(false);
27+
Application.Run(new MainForm());
28+
}
29+
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#region Using directives
2+
3+
using System;
4+
using System.Reflection;
5+
using System.Runtime.InteropServices;
6+
7+
#endregion
8+
9+
// General Information about an assembly is controlled through the following
10+
// set of attributes. Change these attribute values to modify the information
11+
// associated with an assembly.
12+
[assembly: AssemblyTitle("TextBoxMaskInput")]
13+
[assembly: AssemblyDescription("")]
14+
[assembly: AssemblyConfiguration("")]
15+
[assembly: AssemblyCompany("")]
16+
[assembly: AssemblyProduct("TextBoxMaskInput")]
17+
[assembly: AssemblyCopyright("Copyright 2013")]
18+
[assembly: AssemblyTrademark("")]
19+
[assembly: AssemblyCulture("")]
20+
21+
// This sets the default COM visibility of types in the assembly to invisible.
22+
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
23+
[assembly: ComVisible(false)]
24+
25+
// The assembly version has following format :
26+
//
27+
// Major.Minor.Build.Revision
28+
//
29+
// You can specify all the values or you can use the default the Revision and
30+
// Build Numbers by using the '*' as shown below:
31+
[assembly: AssemblyVersion("1.0.*")]

0 commit comments

Comments
 (0)