{
//檢查 Left
DataGridViewColumn col = Dgrid.Columns.GetFirstColumn( DataGridViewElementStates.Displayed, DataGridViewElementStates.None );
if ( col == null )
{
return -1;
}
// Left
else if ( pt.X <> {
return -1;
}
//檢查 Right
col = Dgrid.Columns.GetLastColumn( DataGridViewElementStates.Displayed, DataGridViewElementStates.None );
if ( pt.X > Dgrid.GetColumnDisplayRectangle( col.Index, true ).Right )
{
return -1;
}
//檢查 Bottom
int rowIndex = Dgrid.Rows.GetLastRow( DataGridViewElementStates.Displayed );
if ( rowIndex <>
{
return -1;
}
//檢查 Bottom
int rowIndex = Dgrid.Rows.GetLastRow( DataGridViewElementStates.Displayed );
if ( rowIndex <>
{
return -1;
}
if ( pt.Y > Dgrid.GetRowDisplayRectangle( rowIndex, true ).Bottom )
{
return -1;
}
//檢查 Top
int toFind = -1;
rowIndex = Dgrid.Rows.GetFirstRow( DataGridViewElementStates.Displayed );
if ( rowIndex <>
{
return -1;
}
//檢查 Top
int toFind = -1;
rowIndex = Dgrid.Rows.GetFirstRow( DataGridViewElementStates.Displayed );
if ( rowIndex <>
{
return -1;
}
Rectangle rect = Dgrid.GetRowDisplayRectangle( rowIndex, true );
if ( pt.Y <>
{
return -1;
}
if ( pt.Y <= rect.Bottom )
{
return rowIndex;
}
rowIndex = Dgrid.Rows.GetNextRow( rowIndex, DataGridViewElementStates.Displayed );
while ( rowIndex >= 0 )
{
rect = Dgrid.GetRowDisplayRectangle( rowIndex, true );
if ( rect.Top <= pt.Y && rect.Bottom >= pt.Y )
{
toFind = rowIndex;
rowIndex = -1;
}
else
{
rowIndex = Dgrid.Rows.GetNextRow( rowIndex, DataGridViewElementStates.Displayed );
}
}
return toFind;
}
{
rect = Dgrid.GetRowDisplayRectangle( rowIndex, true );
if ( rect.Top <= pt.Y && rect.Bottom >= pt.Y )
{
toFind = rowIndex;
rowIndex = -1;
}
else
{
rowIndex = Dgrid.Rows.GetNextRow( rowIndex, DataGridViewElementStates.Displayed );
}
}
return toFind;
}

沒有留言:
張貼留言