2013-04-26 2 views
0

mysql에서 테이블을로드하는 중 첫 번째 열 링크를 만들고 싶습니다. 나는 다른 형태의 링크를 의미합니다. 학생 세부 정보를 표시하고 이름을 클릭하면 새로운 양식이 열리고 학생에 대한 모든 정보가 표시됩니다. 누구든지 어떻게해야하는지 알고 있습니까?테이블의 첫 번째 열을 링크로 설정합니다.

DataTable table = new DataTable(); 
MySqlDataAdapter adapsql = new MySqlDataAdapter("SELECT name, surname, dob, sex, nationality, mobile, notes FROM student", connection); 
adapsql.Fill(table); 
dataGridView1.DataSource = table; 
int x = (dataGridView1.RowCount)-1; 
label21.Text = Convert.ToString(x); 

cmd = connection.CreateCommand(); 
cmd.CommandText = @"SELECT * FROM reservation"; 

MySqlDataReader Reader = cmd.ExecuteReader(); 

if (!Reader.HasRows) return; 
while (Reader.Read()) 
{ 
    reservation.Add(Convert.ToInt16(GetDBString("roomID", Reader))); 

} 
Reader.Close(); 
다음과 같은 이벤트에서이 문제를 처리 할 수 ​​

답변

0

:

dataGridView1_CellClick 

datagridiview의 CurrentCell 값을 얻고 두 번째 양식을 열려면이 정보를 사용하고 당신이 거기있는 필드에 필요한 정보를 추가 .

샘플 코드 :

if (this.dataGridView1.CurrentCell != null) 
{ 
    string valueofcell=dataGridView1.CurrentCell.Value.ToString(); 
    // Raise the corresponding form as per you required 
} 
+0

감사합니다! 그것은 굉장히 일했다 :) – QueenOfError

관련 문제