프로젝트 NO : 2011003
[ Form1] : 부모폼 , DataGridView name : datagridview1
[ Form2] : 자식폼
[Form1] 소스
private void btnAdd_Click(object sender, EventArgs e)
{
}
catch (Exception es) {
MessageBox.Show("ERROR" + es.ToString());
}
finally {
conn.Close();
}
}
[ Form1] : 부모폼 , DataGridView name : datagridview1
[ Form2] : 자식폼
[Form1] 소스
private void btnAdd_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
frm.ShowDialog();
frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
frm.ShowDialog();
}
public void frm_FormClosed(object sender, FormClosedEventArgs e)
{
public void frm_FormClosed(object sender, FormClosedEventArgs e)
{
dataGridView1.Update();
ListView("all");
ListView("all");
}
public void ListView(string str)
{
string query = null;
public void ListView(string str)
{
string query = null;
dataGridView1.Rows.Clear();
dataGridView1.Columns.Clear();
dataGridView1.Columns.Clear();
if(str == "all")
{
query = "select * from reader_info order by contents_id asc";
}
{
query = "select * from reader_info order by contents_id asc";
}
try {
conn.Open();
//MySqlDataAdapter adt = new MySqlDataAdapter(query, conn);
adt = new MySqlDataAdapter(query, conn);
//DataSet ds = new DataSet();
ds = new DataSet();
adt = new MySqlDataAdapter(query, conn);
//DataSet ds = new DataSet();
ds = new DataSet();
adt.Fill(ds,"xorbis");
//
dataGridView1.Columns.Add("seqid", "일련번호");
dataGridView1.Columns.Add("contents_id", "컨텐츠정보");
dataGridView1.Columns.Add("pc_ip", "컨텐츠아이피");
dataGridView1.Columns.Add("reader_ip", "리더기아이피");
//
int row = ds.Tables["tbl"].Rows.Count - 1;
for (int r = 0; r <= row; r++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[r].Cells[0].Value = ds.Tables["tbl"].Rows[r].ItemArray[0];
dataGridView1.Rows[r].Cells[1].Value = ds.Tables["tbl"].Rows[r].ItemArray[1];
dataGridView1.Rows[r].Cells[2].Value = ds.Tables["tbl"].Rows[r].ItemArray[2];
dataGridView1.Rows[r].Cells[3].Value = ds.Tables["tbl"].Rows[r].ItemArray[3];
}
//
dataGridView1.Columns.Add("seqid", "일련번호");
dataGridView1.Columns.Add("contents_id", "컨텐츠정보");
dataGridView1.Columns.Add("pc_ip", "컨텐츠아이피");
dataGridView1.Columns.Add("reader_ip", "리더기아이피");
//
int row = ds.Tables["tbl"].Rows.Count - 1;
for (int r = 0; r <= row; r++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[r].Cells[0].Value = ds.Tables["tbl"].Rows[r].ItemArray[0];
dataGridView1.Rows[r].Cells[1].Value = ds.Tables["tbl"].Rows[r].ItemArray[1];
dataGridView1.Rows[r].Cells[2].Value = ds.Tables["tbl"].Rows[r].ItemArray[2];
dataGridView1.Rows[r].Cells[3].Value = ds.Tables["tbl"].Rows[r].ItemArray[3];
}
}
catch (Exception es) {
MessageBox.Show("ERROR" + es.ToString());
}
finally {
conn.Close();
}
}
'프로그래밍 > C#' 카테고리의 다른 글
| IOCP 참고 자료들. (0) | 2011/05/13 |
|---|---|
| MSSQL 연결편. (0) | 2011/05/13 |
| [DataGridView] 자식폼에서 업데이트 후 부모폼에서 GridView Update 방법 (0) | 2011/04/19 |
| [c#]Thread를 이용한 파일복사하기-프로그래스바 (0) | 2011/03/15 |
| Rijndael(AES) 암/복호화 코드(C#) (1) | 2011/02/23 |
| C#으로 Socket programming 하기 (0) | 2010/11/26 |
