0
我有一個包含datagridview的窗體。每當用戶點擊一行時,一個小面板就會出現在行的下方並顯示一些按鈕。如預期工作一切都與下面的代碼:如何防止出現在屏幕外的面板?
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
rowSelected = e.RowIndex;
columnSelected = e.ColumnIndex;
if (e.RowIndex == -1) return;
var cellRectangle = dataGridView1.PointToScreen(
dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
panel_EditButtons.Location = new Point(cellRectangle.X + 50, cellRectangle.Y);
panel_EditButtons.Show();
}
能有一個人請告訴我如何防止面板出現了屏幕的時候對行的用戶點擊,也沒有足夠的空間來顯示面板?觀察這兩種圖像I附:
普通視圖(當有足夠的空間來顯示面板時,面板顯示正確)
當我點擊該行的右側(並且沒有足夠的空間來顯示面板,該面板顯示出畫面)
能有一個人請告訴我,我怎麼能顯示完整的面板,甚至當我點擊該行的右側,面板沒有足夠的空間位置僅限於屏幕寬度?