using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DataTable table = null;
private void button1_Click(object sender, EventArgs e)
{
table = new DataTable("classtable");
DataColumn column;
DataRow row;
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "이름";
column.AllowDBNull = false;
table.Columns.Add(column);
column = new DataColumn();
column.DataType = Type.GetType("System.Int32");
column.ColumnName = "국어";
column.AllowDBNull = false;
table.Columns.Add(column);
column = new DataColumn();
column.DataType = Type.GetType("System.Int32");
column.ColumnName = "영어";
column.AllowDBNull = false;
table.Columns.Add(column);
column.DataType = Type.GetType("System.Int32");
column = new DataColumn();
column.ColumnName = "수학";
column.AllowDBNull = false;
table.Columns.Add(column);
column.DataType = Type.GetType("System.Double");
column = new DataColumn();
column.ColumnName = "평균";
column.AllowDBNull = false;
table.Columns.Add(column);
row = table.NewRow();
row[0] = "전광식";
row[1] = 90;
row[2] = 80;
row[3] = 70;
row[4] = (90 + 80 + 70) / 3.0;
table.Rows.Add(row);
row = table.NewRow();
row[0] = "권오윤";
row[1] = 60;
row[2] = 60;
row[3] = 55;
row[4] = (60 + 60 + 55) / 3.0;
table.Rows.Add(row);
row = table.NewRow();
row[0] = "고정욱";
row[1] = 60;
row[2] = 60;
row[3] = 65;
row[4] = (60 + 60 + 65) / 3.0;
table.Rows.Add(row);
dataGrid1.DataSource = table;
}
private void button2_Click(object sender, EventArgs e)
{
try
{
string name = textBox1.Text;
int kor = Convert.ToInt32(textBox2.Text.Trim());
int eng = Convert.ToInt32(textBox3.Text.Trim());
int math = Convert.ToInt32(textBox4.Text.Trim());
int avg = (kor + eng + math) / 3;
DataRow row = table.NewRow();
row[0] = name;
row[1] = kor;
row[2] = eng;
row[3] = math;
row[4] = avg;
table.Rows.Add(row);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
catch
{
MessageBox.Show("입력값이 잘못되었습니다");
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
int index = dataGrid1.CurrentRowIndex;
int kor = Convert.ToInt32(textBox2.Text.Trim());
int eng = Convert.ToInt32(textBox3.Text.Trim());
int math = Convert.ToInt32(textBox4.Text.Trim());
DataRow row = table.Rows[index];
row.BeginEdit();
row[0] = textBox1.Text;
row[1] = kor;
row[2] = eng;
row[3] = math;
row.EndEdit();
MessageBox.Show("편집저장");
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
catch
{
MessageBox.Show("잘못입력");
}
}
private void button4_Click(object sender, EventArgs e)
{
int index = dataGrid1.CurrentRowIndex;
DataRow row = table.Rows[index];
row.Delete();
}
private void button5_Click(object sender, EventArgs e)
{
table.Rows.Clear();
}
private void dataGrid1_MouseMove(object sender, MouseEventArgs e)
{
try
{
int index = dataGrid1.CurrentRowIndex;
DataRow row = table.Rows[index];
textBox1.Text = (string)row[0];
textBox2.Text = Convert.ToString(row[1]);
textBox3.Text = Convert.ToString(row[2]);
textBox4.Text = Convert.ToString(row[3]);
}
catch
{
}
}
}
}
2012년 5월 4일 금요일
피드 구독하기:
댓글 (Atom)
UPBIT is a South Korean company, and people died of suicide cause of coin investment.
UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...
-
[펌] [UNIX/LINUX 명령어] apropos linux 2005/06/28 22:05 수정 삭제 http://blog.naver.com/wiggyz/80014482910 Mr.You의 블로그 | ?? http:...
-
안드로이드 SDK manager를 쓰다보면 XOOM 때문에 업그레이드가 안된다. 먼 계정을 넣으라고 한다. 안깔면 된다. 깔고 싶으면 에러 메시지에 뜨는 사이트 들어가서 회원 가입하면 그만이다. 간단하다. 들어가서 이메일 주소 넣으면 자기...
-
Intel의 새로운 MMX - "KNI" KNI 는 Katmai New Instruction 의 약자이다 . 아는 분들은 잘 알고있겠지만 KATMAI( 이하 카트마이로 부름 ) 는 인텔의 다음번 펜티엄...
댓글 없음:
댓글 쓰기
국정원의 댓글 공작을 지탄합니다.