양식에 2 개의 격자가 있습니다. 하나의 표가 일부 학생 정보로 채워집니다. 그리고 나는 mouse를 dataGridview1 위에 놓았을 때 Popup 같은 다른 gridview를 보여 주거나 다른 DataGridview에 Name 열을 기반으로 한 다른 DataGridview를 채우기를 원합니다.마우스를 가져 가면서 열의 값을 가져 오는 방법
그리드가 팝업으로 표시되는 부분을 마우스로 따라갔습니다. 이 그리드 잎 또한 때 사라집니다 :
private void dataGridView1_MouseHover(object sender, EventArgs e)
{
SqlDataAdapter da2;
DataTable dt2 = new DataTable();
da2 = new SqlDataAdapter("SELECT ID, Name, Surname, City"+
"FROM tblStudents2" +
"WHERE Name = **what to write here**", con);
da2.Fill(dt2);
dataGridView2.DataSource = dt2;
}
private void dataGridView1_MouseLeave(object sender, EventArgs e)
{
dataGridView2.Visible = false;
}
private void dataGridView1_MouseMove(object sender, MouseEventArgs e)
{
dataGridView2.Visible = true;
dataGridView2.Location = new Point(MousePosition.X-100, MousePosition.Y-100);
}
을 그냥 부분에서, 나는에게 SQL 문을 어떻게 작성하는 당신을 물어보고 싶은 : 이름 = '_ __ _' ??
Mous가 첫 번째 행 위에있을 때 Name (열 인덱스 1)을 가져 와서 다른 DataGrid를 채우기를 원합니다. 나는 희망
당신이 날 :(이해
는***은 그렇지 않습니다 * ... 여기 내 코드는 에산의 코드를 거쳐입니다 편집이 거의. 문제가 workes 다음 행으로 마우스를 이동 한 후 그리드를 다시 채 웁니다 !! Butif DataGrid를두고 다른 행에 마우스를 올려 놓으면이 행의 ifnormation이 표시됩니다. 마우스를 움직여 새로 고침 그리드를 만드는 방법 다음 행?
public void LoadGridi2()
{
SqlDataAdapter da2;
DataTable dt2 = new DataTable();
da2 = new SqlDataAdapter("SELECT ID, Name, Surname, City FROM tblMentori WHERE Name = '" + dataGridView1.Rows[row.Index].Cells[1].Value.ToString() + "'", con);
da2.Fill(dt2);
dataGridView2.DataSource = dt2;
}
private void dataGridView1_MouseHover(object sender, EventArgs e)
{
LoadGridi2();
}
private void dataGridView1_MouseLeave(object sender, EventArgs e)
{
dataGridView2.Visible = false;
}
DataGridViewRow row;
private void dataGridView1_MouseMove(object sender, MouseEventArgs e)
{
dataGridView2.Visible = true;
dataGridView2.Location = new Point(MousePosition.X - 100, MousePosition.Y - 100);
}
private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex >= 0)
{
row = (DataGridViewRow)dataGridView1.Rows[e.RowIndex];
}
}
여기에 내 대답을 참조 http://stackoverflow.com/questions/17771973/usage-of-tooltip-in-c-net-4-0/17772017#17772017 – Ehsan
@EhsanUllah, 귀하의 답변은 목록 상자 용입니다 ... DataGrid? – user2478115
예 아이디어가 동일합니다. 어쨌든 나는 데이터 갤러리 용 답변을 게시했습니다 – Ehsan