99 multiplication table based on C#winform the last time I did homework, I made a 99 multiplication table based on C # form, in which we can make a summary, so that we can communicate with you easily.
Production ideas for customizing some lable controls, the contents of the multiplication table are displayed on the control, and the results appear when the corresponding content is clicked.
Operation Result:
Click-Time Effect:
When the form loads:
When you click Label:
Full code:
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 multiplication table
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}
Private label[] Lab = new LABEL[100];
private void OnClick (object sender, EventArgs e)//Click to show Results
{
String k = ((Label) sender). Text; If the result appears, click again to return
if (K.length > 5)
Return
String Jieguo = ((Label) sender). Name; The name of each lable is the location where the lable is located when the form is loaded and the label is set
String AA =convert.tostring (jieguo[0]);
int a = Convert.ToInt32 (AA);
string bb = convert.tostring (jieguo[1]);
int b = Convert.ToInt32 (BB);
int c = A * b;
((Label) sender). Text + = "=" + c.tostring ();
}
String s = "";
private void Form1_Load (object sender, EventArgs e)
{
This. Width = 800; The width of the form
This. Height = 600; Form's high
This. BackColor = Color.White; Background color A of a form
int w = 80; Width of the control
int h = 50; Height of the control
for (int i = 1; i < i++)//9 line
{
for (int j = i * 10+1; J < I * + i+1; j + +)//number of lines per line
{
LAB[J] = new Label ();
if (J > I * 10+1)
{
LAB[J]. left = Lab[j-1]. Left + W; Where's the space?
}
Else
{
LAB[J]. left = 30; Left margin of first column
}
s = convert.tostring (j);
LAB[J]. Name = s; Control's name
LAB[J]. Text = s[1]+ "*" + (s[0]); Word displayed on the control
LAB[J]. Width = W; The width of the control
LAB[J]. Height = h; Control's high
LAB[J]. BackColor = Color.hotpink; Label's background color
LAB[J]. Top = (J/10) * H; Top margin of the control
This. Controls.Add (Lab[j]); Join this control
LAB[J]. Click + = new EventHandler (OnClick); Click events
}
}
}
}
}
Source code Download Path: http://pan.baidu.com/s/1i3mVWC9
99 multiplication table based on C#winform