Windows Calculator Complete…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

double textboxnumber;
long first;
long second;
private void button15_Click(object sender, EventArgs e)
{
{
double a1, b1, c1;
string s = null;
string t = null;
char[] x = textBox1.Text.ToCharArray();
if (textBox1.Text == null)
{
throw new ArgumentNullException();
}
try
{
for (int a = 0; a < x.Length; a++)
{
if (x[a] == ‘+’)
{
for (int b = 0; b < a; b++)
{

s += x[b].ToString();

}
for (int g = a; g < x.Length; g++)
{
t += x[g].ToString();

}

a1 = double.Parse(s);
b1 = double.Parse(t);
c1 = a1 + b1;
textBox1.Text = c1.ToString();
}
}
for (int a = 0; a < x.Length; a++)
{
if (x[a] == ‘-‘)
{
for (int b = 0; b < a; b++)
{

s += x[b].ToString();

}
for (int g = a + 1; g < x.Length; g++)
{
t += x[g].ToString();

}

a1 = double.Parse(s);
b1 = double.Parse(t);
c1 = a1 – b1;
textBox1.Text = c1.ToString();
}
}
for (int a = 0; a < x.Length; a++)
{
if (x[a] == ‘*’)
{
for (int b = 0; b < a; b++)
{

s += x[b].ToString();

}
for (int g = a + 1; g < x.Length; g++)
{
t += x[g].ToString();

}

a1 = double.Parse(s);
b1 = double.Parse(t);
c1 = a1 * b1;
textBox1.Text = c1.ToString();
}
}
for (int a = 0; a < x.Length; a++)
{
if (x[a] == ‘/’)
{
for (int b = 0; b < a; b++)
{

s += x[b].ToString();

}
for (int g = a + 1; g < x.Length; g++)
{
t += x[g].ToString();

}

a1 = double.Parse(s);
b1 = double.Parse(t);
c1 = a1 / b1;
textBox1.Text = c1.ToString();
}
}
second = (long)(textboxnumber);
label1.Text = “”;
if (difference == 1)
{
textBox1.Text = Permutation(first, second).ToString();
}
else if(difference == 2)
textBox1.Text = Combinatorial(first, second).ToString();
}
catch
{

textBox1.Text = “Enter a correct value”;

}
}
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += “1”;
}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += “2”;
}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += “3”;
}

private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += “4”;
}

private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += “5”;
}

private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += “6”;
}

private void button7_Click(object sender, EventArgs e)
{
textBox1.Text += “7”;
}

private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += “8”;
}

private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += “9”;
}

private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += “0”;
}

private void button11_Click(object sender, EventArgs e)
{
textBox1.Text += “+”;
}

private void button13_Click(object sender, EventArgs e)
{
textBox1.Text += “*”;
}

private void button12_Click(object sender, EventArgs e)
{
textBox1.Text += “-“;
}

private void button14_Click(object sender, EventArgs e)
{
textBox1.Text += “/”;
}

private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = “”;
}

private void Form1_MouseClick(object sender, MouseEventArgs e)
{

}

private void button17_Click(object sender, EventArgs e)
{
try
{
textBox1.Text = Math.Sin(textboxnumber).ToString();
}
catch
{
textBox1.Text = “Enter the correct value”;

}

}

private void button18_Click(object sender, EventArgs e)
{
try
{
textBox1.Text = Math.Cos(textboxnumber).ToString();
}
catch
{
textBox1.Text = “Enter the correct value”;
}

}

private void button19_Click(object sender, EventArgs e)
{

{
textBox1.Text = Math.Tan(textboxnumber).ToString();
}

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
textboxnumber = double.Parse(textBox1.Text);

}
catch
{

}

}

public  long Factorial(long number)
{
if (number <= 1) return 1;
return  number * Factorial(number – 1);
}
public long Permutation(long n, long r)
{
if (r == 0) return 0;
if (n == 0) return 0;
if ((r >= 0) && (r <= n))
return Factorial(n) / Factorial(n – r);
else return 0;
}
public long Combinatorial(long a, long b)
{
if (a <= 1) return 1;
return Factorial(a) / ((Factorial(b) * Factorial(a – b)));
}

long factor1;
private void button20_Click(object sender, EventArgs e)
{
long factor = 0;

factor = (long)(textboxnumber);

factor1 = Factorial(factor);
textBox1.Text = factor1.ToString();
//  textBox3.Text = exo.Permutation(factor, second).ToString();
//textBox4.Text = exo.Combinatorial(factor, second).ToString();
}
int difference = 0;
private void button21_Click(object sender, EventArgs e)
{

difference = 1;
first = (long)(textboxnumber);
label1.Text = “enter second number”;
textBox1.Clear();

}

private void button22_Click(object sender, EventArgs e)
{

difference = 2;
first = (long)(textboxnumber);
label1.Text = “enter second number”;
textBox1.Clear();

}

}
}

Advertisements

Common Tool Box Properties …

Form properties,
methods and an event Description
Common Properties
AcceptButton Button that is clicked when Enter is pressed.
AutoScroll bool value that allows or disallows scrollbars when needed.
CancelButton Button that is clicked when the Escape key is pressed.
FormBorderStyle Border style for the Form (e.g., none, single, three-dimensional).
Font Font of text displayed on the Form, and the default font for controls
added to the Form.
Text Text in the Form’s title bar.
Common Methods
Close Closes a Form and releases all resources, such as the memory used
for the Form’s contents. A closed Form cannot be reopened.
Hide Hides a Form, but does not destroy the Form or release its resources.
Show Displays a hidden Form.
Common Event
Load Occurs before a Form is displayed to the user. The handler for this
event is displayed in the Visual Studio editor when you double
click the Form in the Visual Studio designer.

Class Control
properties and
methods Description
Common Properties
BackColor The control’s background color.
BackgroundImage The control’s background image.
Enabled Specifies whether the control is enabled (i.e., if the user can interact with
it). Typically, portions of a disabled control appear “grayed out” as a
visual indication to the user that the control is disabled.
Focused Indicates whether the control has the focus.
Font The Font used to display the control’s text.
ForeColor The control’s foreground color. This usually determines the color of the
text in the Text property.
TabIndex The tab order of the control. When the Tab key is pressed, the focus
transfers between controls based on the tab order. You can set this order.
TabStop If true, then a user can give focus to this control via the Tab key.
Text The text associated with the control. The location and appearance of the
text vary depending on the type of control.
Visible Indicates whether the control is visible.
Common Methods
Hide Hides the control (sets the Visible property to false).
Select Acquires the focus.
Show Shows the control (sets the Visible property to true).

Control layout
properties Description
Anchor Causes a control to remain at a fixed distance from the side(s) of the container
even when the container is resized.
Dock Allows a control to span one side of its container or to fill the remaining
space in the container.
Padding Sets the space between a container’s edges and docked controls. The
default is 0, causing the control to appear flush with the container’s sides.
Location Specifies the location (as a set of coordinates) of the upper-left corner of
the control, in relation to its container’s upper-left corner.
Size Specifies the size of the control in pixels as a Size object, which has properties
Width and Height.
MinimumSize,
MaximumSize
Indicates

Common Label
properties Description
Font The font of the text on the Label.
Text The text on the Label.
TextAlign The alignment of the Label’s text on the control—horizontally
(left, center or right) and vertically (top, middle or bottom).
The default is top, left.

TextBox properties
and an event Description
Common Properties
AcceptsReturn If true in a multiline TextBox, pressing Enter in the TextBox creates a
new line. If false (the default), pressing Enter is the same as pressing
the default Button on the Form. The default Button is the one assigned
to a Form’s AcceptButton property.
Multiline If true, the TextBox can span multiple lines. The default value is false.
ReadOnly If true, the TextBox has a gray background, and its text cannot be
edited. The default value is false.
ScrollBars For multiline textboxes, this property indicates which scrollbars appear
(None—the default, Horizontal, Vertical or Both).
Text The TextBox’s text content.
UseSystem-
PasswordChar
When true, the TextBox becomes a password TextBox, and the systemspecified
character masks each character the user types.
Common Event
TextChanged Generated when the text changes in a TextBox (i.e., when the user adds
or deletes characters). When you double click the TextBox control in
Design mode, an empty event handler for this event is generated.

Button properties
and an event Description
Common Properties
Text Specifies the text displayed on the Button face.
FlatStyle Modifies a Button’s appearance—attribute Flat (for the Button to display
without a three-dimensional appearance), Popup (for the Button to
appear flat until the user moves the mouse pointer over the Button),
Standard (three-dimensional) and System, where the Button’s appearance
is controlled by the operating system. The default value is Standard.
Common Event
Click Generated when the user clicks the Button. When you double click a
Button in design view, an empty event handler for this event is created.

GroupBox properties Description
Controls The set of controls that the GroupBox contains.
Text Specifies the caption text displayed at the top of the GroupBox.

Panel properties Description
AutoScroll Indicates whether scrollbars appear when the Panel is too small to
display all of its controls. The default value is false.
BorderStyle Sets the border of the Panel. The default value is None; other
options are Fixed3D and FixedSingle.
Controls The set of controls that the Panel contains.

CheckBox properties
and events Description
Common Properties
Appearance By default, this property is set to Normal, and the CheckBox displays
as a traditional checkbox. If it’s set to Button, the CheckBox displays
as a Button that looks pressed when the CheckBox is checked.
Checked Indicates whether the CheckBox is checked (contains a check mark)
or unchecked (blank). This property returns a bool value. The
default is false (unchecked).
CheckState Indicates whether the CheckBox is checked or unchecked with a
value from the CheckState enumeration (Checked, Unchecked or
Indeterminate). Indeterminate is used when it’s unclear whether
the state should be Checked or Unchecked. When CheckState is set to
Indeterminate, the CheckBox is usually shaded.
Text Specifies the text displayed to the right of the CheckBox.
ThreeState When this property is true, the CheckBox has three states—checked,
unchecked and indeterminate. By default, this property is false and
the CheckBox has only two states—checked and unchecked.
Common Events
CheckedChanged Generated when the Checked property changes. This is a CheckBox’s
default event. When a user double clicks the CheckBox control in
design view, an empty event handler for this event is generated.
CheckStateChanged Generated when the CheckState property changes.

RadioButton
properties and an event Description
Common Properties
Checked Indicates whether the RadioButton is checked.
Text Specifies the RadioButton’s text.
Common Event
CheckedChanged Generated every time the RadioButton is checked or unchecked.
When you double click a RadioButton control in design view, an
empty event handler for this event is generated.

PictureBox properties
and an event Description
Common Properties
Image Sets the image to display in the PictureBox.
SizeMode Enumeration that controls image sizing and positioning. Values
are Normal (default), StretchImage, AutoSize, CenterImage, and
Zoom. Normal places the image in the PictureBox’s top-left corner,
and CenterImage puts the image in the middle. These two options
truncate the image if it’s too large. StretchImage resizes the image
to fit in the PictureBox. AutoSize resizes the PictureBox to hold
the image. Zoom resizes the image to to fit the PictureBox but
maintains the original aspect ratio.
Common Event
Click Occurs when the user clicks a control. When you double click this
control in the designer, an event handler is generated for this
event.

ToolTip properties
and an event Description
Common Properties
AutoPopDelay The amount of time (in milliseconds) that the tool tip appears while
the mouse is over a control.
InitialDelay The amount of time (in milliseconds) that a mouse must hover over a
control before a tool tip appears.
ReshowDelay The amount of time (in milliseconds) between which two different tool
tips appear (when the mouse is moved from one control to another).
Common Event
Draw Raised when the tool tip is displayed. This event allows programmers
to modify the appearance of the tool tip.

NumericUpDown
properties and an event Description
Common Properties
DecimalPlaces Specifies how many decimal places to display in the control.
Increment Specifies by how much the current number in the control
changes when the user clicks the control’s up and down arrows.

NumericUpDown
properties and an event DescriptionMaximum Largest value in the control’s range.
Minimum Smallest value in the control’s range.
UpDownAlign Modifies the alignment of the up and down Buttons on the
NumericUpDown control. This property can be used to display
these Buttons either to the left or to the right of the control.
Value The numeric value currently displayed in the control.
Common Event
ValueChanged This event is raised when the value in the control is changed.
This is the default event for the NumericUpDown control.

Mouse events and event arguments
Mouse Events with Event Argument of Type EventArgs
MouseEnter Occurs when the mouse cursor enters the control’s boundaries.
MouseHover Occurs when the mouse cursor hovers within the control’s boundaries.
MouseLeave Occurs when the mouse cursor leaves the control’s boundaries.
Mouse Events with Event Argument of Type MouseEventArgs
MouseDown Occurs when a mouse button is pressed while the mouse cursor is within a
control’s boundaries.
MouseMove Occurs when the mouse cursor is moved while in the control’s boundaries.
MouseUp Occurs when a mouse button is released when the cursor is over the control’s
boundaries.
Class MouseEventArgs Properties
Button Specifies which mouse button was pressed (Left, Right, Middle or None).
Clicks The number of times that the mouse button was clicked.
X The x-coordinate within the control where the event occurred.
Y The y-coordinate within the control where the event occurred.

Keyboard events and event arguments
Key Events with Event Arguments of Type KeyEventArgs
KeyDown Generated when a key is initially pressed.
KeyUp Generated when a key is released.
Key Event with Event Argument of Type KeyPressEventArgs
KeyPress Generated when a key is pressed. Raised after KeyDown and before KeyUp.
Class KeyPressEventArgs Properties
KeyChar Returns the ASCII character for the key pressed.
Class KeyEventArgs Properties
Alt Indicates whether the Alt key was pressed.
Control Indicates whether the Ctrl key was pressed.
Shift Indicates whether the Shift key was pressed.
KeyCode Returns the key code for the key as a value from the Keys enumeration. This
does not include modifier-key information. It’s used to test for a specific key.
KeyData Returns the key code for a key combined with modifier information as a Keys
value. This property contains all information about the pressed key.
KeyValue Returns the key code as an int, rather than as a value from the Keys enumeration.
This property is used to obtain a numeric representation of the pressed
key. The int value is known as a Windows virtual key code.
Modifiers Returns a Keys value indicating any pressed modifier keys (Alt, Ctrl and Shift).
This property is used to determine modifier-key information only.

MenuStrip and
ToolStripMenuItem
properties and an event Description
MenuStrip Properties
RightToLeft Causes text to display from right to left. This is useful for languages
that are read from right to left.
ToolStripMenuItem Properties
Checked Indicates whether a menu item is checked. The default value is
false, meaning that the menu item is unchecked.
CheckOnClick Indicates that a menu item should appear checked or unchecked as
it is clicked.
ShortcutKey-
DisplayString
Specifies text that should appear beside a menu item for a shortcut
key. If left blank, the key names are displayed. Otherwise, the text
in this property is displayed for the shortcut key.
ShortcutKeys Specifies the shortcut key for the menu item (e.g., <Ctrl>-F9 is
equivalent to clicking a specific item).
ShowShortcutKeys Indicates whether a shortcut key is shown beside menu item text.
The default is true, which displays the shortcut key.
Text Specifies the menu item’s text. To create an Alt access shortcut, precede
a character with & (e.g., &File to specify a menu named File
with the letter F underlined).
Common ToolStripMenuItem Event
Click Generated when an item is clicked or a shortcut key is used. This is
the default event when the menu is double clicked in the designer.

MonthCalendar
properties and an event Description
MonthCalendar Properties
FirstDayOfWeek Sets which day of the week is the first displayed for each week in
the calendar.
MaxDate The last date that can be selected.
MaxSelectionCount The maximum number of dates that can be selected at once.
MinDate The first date that can be selected.
MonthlyBoldedDates An array of dates that will displayed in bold in the calendar.
SelectionEnd The last of the dates selected by the user.
SelectionRange The dates selected by the user.
SelectionStart The first of the dates selected by the user.
Common MonthCalendar Event
DateChanged Generated when a date is selected in the calendar.

DateTimePicker
properties and an event Description
DateTimePicker Properties
CalendarForeColor Sets the text color for the calendar.
CalendarMonth-
Background
Sets the calendar’s background color.
CustomFormat Sets the custom format string for the user’s options.
Format Sets the format of the date and/or time used for the
user’s options.
MaxDate The maximum date and time that can be selected.
MinDate The minimum date and time that can be selected.
ShowCheckBox Indicates if a CheckBox should be displayed to the left
of the selected date and time.
ShowUpDown Indicates whether the control displays up and down
Buttons. Helpful when the DateTimePicker is used to
select a time—the Buttons can be used to increase or
decrease hour, minute and second.
Value The data selected by the user.
Common DateTimePicker Event
ValueChanged Generated when the Value property changes, including
when the user selects a new date or time.

LinkLabel properties
and an event Description
Common Properties
ActiveLinkColor Specifies the color of the active link when the user is in the process of
clicking the link. The default color (typically red) is set by the system.
LinkArea Specifies which portion of text in the LinkLabel is part of the link.
LinkBehavior Specifies the link’s behavior, such as how the link appears when the
mouse is placed over it.
LinkColor Specifies the original color of the link before it’s been visited. The
default color (typically blue) is set by the system.
LinkVisited If true, the link appears as though it has been visited (its color is
changed to that specified by property VisitedLinkColor). The
default value is false.
Text Specifies the control’s text.
UseMnemonic If true, the & character in the Text property acts as a shortcut (similar
to the Alt shortcut in menus).
VisitedLinkColor Specifies the color of a visited link. The default color (typically purple)
is set by the system.
Common Event (Event arguments LinkLabelLinkClickedEventArgs)
LinkClicked Generated when the link is clicked. This is the default event when
the control is double clicked in Design mode.

ListBox properties,
methods and an event Description
Common Properties
Items The collection of items in the ListBox.
MultiColumn Indicates whether the ListBox can display multiple columns. Multiple
columns eliminate vertical scrollbars from the display.
SelectedIndex Returns the index of the selected item. If no items have been
selected, the property returns -1. If the user selects multiple items,
this property returns only one of the selected indices. If multiple
items are selected, use property SelectedIndices.
SelectedIndices Returns a collection containing the indices for all selected items.
SelectedItem Returns a reference to the selected item. If multiple items are
selected, it returns the item with the lowest index number.
SelectedItems Returns a collection of the selected item(s).
SelectionMode Determines the number of items that can be selected and the means
through which multiple items can be selected. Values None, One (the
default), MultiSimple (multiple selection allowed) or MultiExtended
(multiple selection allowed using a combination of arrow
keys or mouse clicks and Shift and Ctrl keys).
Sorted Indicates whether items are sorted alphabetically. Setting this property’s
value to true sorts the items. The default value is false.
Common Methods
ClearSelected Deselects every item.
GetSelected Returns true if the item at the specified index is selected.
Common Event
SelectedIndexChanged Generated when the selected index changes. This is the default
event when the control is double clicked in the designer.

CheckedListBox
properties, a method
and an event Description
Common Properties (All the ListBox properties, methods and events are inherited by
CheckedListBox.)
CheckedItems Returns the collection of items that are checked as a CheckedList-
Box.CheckedItemCollection. This is distinct from the selected item,
which is highlighted (but not necessarily checked). [Note: There can
be at most one selected item at any given time.]
CheckedIndices Returns indices for all checked items as a CheckedListBox.Checked-
IndexCollection.
CheckOnClick When true and the user clicks an item, the item is both selected and
checked or unchecked. By default, this property is false, which
means that the user must select an item, then click it again to check
or uncheck it.
SelectionMode Determines whether items can be selected and checked. The possible
values are One (the default; allows multiple checks to be placed) or
None (does not allow any checks to be placed).
Common Method
GetItemChecked Takes an index and returns true if the corresponding item is
checked.
Common Event (Event arguments ItemCheckEventArgs)
ItemCheck Generated when an item is checked or unchecked.
ItemCheckEventArgs Properties
CurrentValue Indicates whether the current item is checked or unchecked. Possible
values are Checked, Unchecked and Indeterminate.
Index Returns the zero-based index of the item that changed.
NewValue Specifies the new state of the item.

ComboBox properties
and an event Description
Common Properties
DropDownStyle Determines the type of ComboBox. Value Simple means that the text
portion is editable and the list portion is always visible. Value
DropDown (the default) means that the text portion is editable but
the user must click an arrow button to see the list portion. Value
DropDownList means that the text portion is not editable and the
user must click the arrow button to see the list portion.
Items The collection of items in the ComboBox control.
MaxDropDownItems Specifies the maximum number of items (between 1 and 100) that
the drop-down list can display. If the number of items exceeds the
maximum number of items to display, a scrollbar appears.
SelectedIndex Returns the index of the selected item, or -1 if none are selected.
SelectedItem Returns a reference to the selected item.
Sorted Indicates whether items are sorted alphabetically. Setting this property’s
value to true sorts the items. The default is false.
Common Event
SelectedIndexChanged Generated when the selected index changes (such as when a different
item is selected). This is the default event when control is double
clicked in the designer.

TreeView properties
and an event Description
Common Properties
CheckBoxes Indicates whether CheckBoxes appear next to nodes. A value of true
displays CheckBoxes. The default value is false.
ImageList Specifies an ImageList object containing the node icons. An Image-
List object is a collection that contains Image objects.
Nodes Returns the collection of TreeNodes in the control as a TreeNodeCollection.
It contains methods Add (adds a TreeNode object), Clear
(deletes the entire collection) and Remove (deletes a specific node).
Removing a parent node deletes all of its children.
SelectedNode The selected node.
Common Event (Event arguments TreeViewEventArgs)
AfterSelect Generated after selected node changes. This is the default event when
the control is double clicked in the designer.

TreeNode properties
and methods Description
Common Properties
Checked Indicates whether the TreeNode is checked (CheckBoxes property must
be set to true in the parent TreeView).
FirstNode Specifies the first node in the Nodes collection (i.e., the first child in
the tree).
FullPath Indicates the path of the node, starting at the root of the tree.
ImageIndex Specifies the index in the TreeView’s ImageList of the image shown
when the node is deselected.
LastNode Specifies the last node in the Nodes collection (i.e., the last child in the
tree).
NextNode Next sibling node.
Nodes Collection of TreeNodes contained in the current node (i.e., all the
children of the current node). It contains methods Add (adds a Tree-
Node object), Clear (deletes the entire collection) and Remove (deletes
a specific node). Removing a parent node deletes all of its children.
PrevNode Previous sibling node.
SelectedImageIndex Specifies the index in the TreeView’s ImageList of the image to use
when the node is selected.
Text Specifies the TreeNode’s text.
Common Methods
Collapse Collapses a node.
Expand Expands a node.
ExpandAll Expands all the children of a node.
GetNodeCount Returns the number of child nodes.

ListView properties
and events Description
Common Properties
Activation Determines how the user activates an item. This property takes a
value in the ItemActivation enumeration. Possible values are
OneClick (single-click activation), TwoClick (double-click activation,
item changes color when selected) and Standard (the default; double-
click activation, item does not change color).
CheckBoxes Indicates whether items appear with CheckBoxes. true displays
CheckBoxes. The default is false.
LargeImageList Specifies the ImageList containing large icons for display.
Items Returns the collection of ListViewItems in the control.
MultiSelect Determines whether multiple selection is allowed. The default is
true, which enables multiple selection.
SelectedItems Returns the collection of selected items as a ListView.SelectedListViewItemCollection.
SmallImageList Specifies the ImageList containing small icons for display.
View Determines appearance of ListViewItems. Possible values are
LargeIcon (the default; large icon displayed, items can be in multiple
columns), SmallIcon (small icon displayed, items can be in multiple
columns), List (small icons displayed, items appear in a single
column), Details (like List, but multiple columns of information
can be displayed per item) and Tile (large icons displayed, information
provided to right of icon; valid only in Windows XP or later).
Common Events
Click Generated when an item is clicked. This is the default event.
ItemActivate Generated when an item in the ListView is activated (clicked or double
clicked). Does not contain the specifics of which item is activated.

TabControl
properties and an
event Description
Common Properties
ImageList Specifies images to be displayed on tabs.
ItemSize Specifies the tab size.
Multiline Indicates whether multiple rows of tabs can be displayed.
SelectedIndex Index of the selected TabPage.
SelectedTab The selected TabPage.
TabCount Returns the number of tab pages.
TabPages Returns the collection of TabPages within the TabControl as a Tab-
Control.TabPageCollection.
Common Event
SelectedIndexChanged Generated when SelectedIndex changes (i.e., another TabPage is
selected).

How to Crypt Data simple and very efficient …

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}
string unicodeString = “”;
Byte[] encodedBytes = new Byte[] { };
ASCIIEncoding ascii = new ASCIIEncoding();

Byte[] decodeBytes = new Byte[] { };

string decodedString = “”;
string set = “”;
char[] check;
Byte byteValue = 0;
// int app = 0;
string s = “”;
//char[] go;

private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = “”;

// char[] alpha = new char[]{‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’};
// string s=””;

try
{

unicodeString = textBox1.Text;
unicodeString = unicodeString.ToLower();
encodedBytes = ascii.GetBytes(unicodeString);
int length = unicodeString.Length;

foreach (Byte b in encodedBytes)
{
//decodeBytes[0] =  (Byte)(b+5);
set += (b + 5).ToString();
// app += (int)(b + 5);
byteValue = (Byte)(b + length);
if (byteValue >= 123)
{
byteValue = (Byte)(byteValue – 26);

}
// s = System.Text.ASCIIEncoding.ASCII.GetString(encodedBytes);
//label1.Text=byteValue.ToString();
decodeBytes = BitConverter.GetBytes(byteValue);
s = ascii.GetString(decodeBytes);
//s += decodeBytes.ToString();

check = s.ToCharArray();

//check [] = set;

//if (check[a] == ‘%’)
//   check[a] = ‘ ‘;

//textBox2.Text += check[a];

//string.replac(decodeString,””);
// decodedString =  Regex.Replace(s, “[^a-zA-Z0-9]”, ” “, RegexOptions.Compiled);
// decodedString = decodedString.replace(“[^a-zA-Z0-9]”, “_”);
Regex re = new Regex(“[;\\\\/:*?\”<>|&%#’]”);
//

decodedString = re.Replace(s, ” “);

textBox2.Text += decodedString;

}

// foreach (Byte z in byteValue)
{

//   decodedString += z.ToString();
}

//decodeBytes = Encoding.ASCII.GetBytes(set);

//decodedString = ascii.GetString(byteValue);
//string s = System.Text.ASCIIEncoding.ASCII.GetString(decodeBytes);
// label2.Text = decodeBytes.ToString();

}
catch (FormatException)
{

textBox1.Text = “Invalid value”;

}
catch
{

textBox1.Text = “Wrong input”;
}
}

private void button2_Click(object sender, EventArgs e)
{
textBox3.Text = “”;
unicodeString = textBox1.Text;
unicodeString = unicodeString.ToLower();
encodedBytes = ascii.GetBytes(unicodeString);
int length = unicodeString.Length;

foreach (Byte b in encodedBytes)
{
//decodeBytes[0] =  (Byte)(b+5);
set += (b – 5).ToString();
// app += (int)(b + 5);
byteValue = (Byte)(b – length);
if (byteValue <= 96)
{
byteValue = (Byte)(byteValue + 26);

}
// s = System.Text.ASCIIEncoding.ASCII.GetString(encodedBytes);
//label1.Text = byteValue.ToString();
decodeBytes = BitConverter.GetBytes(byteValue);
s = ascii.GetString(decodeBytes);
//s += decodeBytes.ToString();

check = s.ToCharArray();

//check [] = set;

//if (check[a] == ‘%’)
//   check[a] = ‘ ‘;

//textBox2.Text += check[a];

//string.replac(decodeString,””);
// decodedString =  Regex.Replace(s, “[^a-zA-Z0-9]”, ” “, RegexOptions.Compiled);
// decodedString = decodedString.replace(“[^a-zA-Z0-9]”, “_”);
Regex re = new Regex(“[;\\\\/:*?\”<>|&%#0-9’A-Z]”);
//

decodedString = re.Replace(s, ” “);

textBox3.Text += decodedString;
}

}
}
}

Retrieval of Data from Sql Data Base …

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication17
{
public partial class Form1 : Form
{
public OleDbConnection conn = new OleDbConnection();

public Form1()
{
InitializeComponent();

string s = “provider= Microsoft.jet.oledb.4.0; data source= E:\\UIT\\Visual Programming CS201 by Syed Faisal Ali\\Week 7\\Nwind.mdb”;
conn.ConnectionString = s;
conn.Open();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

OleDbCommand cmd = new OleDbCommand();

//Assign SQL statement to the command object
cmd.CommandText = “select LastName from Employees”;
// Define the type of execution , TEXT means SQL Statement
cmd.CommandType = CommandType.Text;
// Assign active open connection to the command, so that the command will be executed on a particular connection

cmd.Connection = conn;

// Reader is used to hold data that is retured by the SQL query. The data is returned when the command is executed .
OleDbDataReader r = cmd.ExecuteReader();
// Loop until data is available in the Reader , one by one
while (r.Read())
{
// Add each record to the comboBox
comboBox1.Items.Add(r.GetString(0));

}

// Closed  reader then connection, to released the memory hold by these objects
r.Close();
conn.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

// open conection Because it was closed earlier
conn.Open();
// Define another Command object
OleDbCommand cmdS = new OleDbCommand();

// We want to select the name of the customers , who’s ID is been selected at the ComboBox by the user.
cmdS.CommandText = “select FirstName from Employees where LastName='” + comboBox1.Text + “‘”;

cmdS.CommandType = CommandType.Text;
cmdS.Connection = conn;
OleDbDataReader r1 = cmdS.ExecuteReader();
while (r1.Read())
{
// Fill the textbox by the data returned by the SQL Query against the Customer ID
textBox1.Text = r1.GetString(0);
}
r1.Close();
conn.Close();

}
}

}

Simple ADO.Net Login

ADO.NET is a large set of .NET classes that enable us to retrieve and manipulate data, and update data sources, in very many different ways. As an essential part of the .NET framework, it shares many of its features: features such as multi-language support, garbage collection, just-in-time compilation, object-oriented design, and dynamic caching, and is far more than an upgrade of previous versions of ADO. ADO.NET is set to become a core component of any data-driven .NET application or Web Service, and understanding its power will be essential to anyone wishing to utilize .NET data maintain to maximum effect.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection(@”Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\shahrooz\Desktop\login.accdb;Persist Security Info=True”);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand(“select * from login where username ='” + maskedTextBox1.Text + “‘”, con);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (maskedTextBox1.Text == dr[0].ToString())
{
if (maskedTextBox2.Text == dr[1].ToString())
{
MessageBox.Show(“i Sucesss “);
}
else
{
MessageBox.Show(“Incorrect Password”, “Information”);
}
}
}
con.Close();
dr.Close();
}
}
}