Come programmatore commerciale, io uso un C# DLL per gestire tutti i miei progetti DataGridView che mi dà la libertà di lingua per qualsiasi progetto mi impegno. Tutti i miei programmi intrappolano tutti i tasti premuti in modo che io possa usarli per i miei scopi. Per lo scorrimento di DataGridView, utilizzo i tasti PageUp/PageDown per una singola pagina, Ctrl/Page per la singola riga e Alt/Page per alto (Su) e in basso (Giù). Codice C# e sequenza di chiamata di base come segue:
//---------- C# Dll Partial Source -----------
public int RowShow
{ get { return vu.DisplayedRowCount(false); } }
public int RowCount
{ get { return vu.RowCount; } }
public void PageMove(int rows)
{
int rowlimit = vu.RowCount - 1;
int calc = vu.FirstDisplayedScrollingRowIndex + rows;
if (calc > rowlimit) calc = rowlimit; // Go to bottom
if (calc < 0) calc = 0; // Go to top
vu.FirstDisplayedScrollingRowIndex = calc;
}
// ---------- End Data Grid View ----------
//---------- Calling Program C# ----------
public void Page_Key(int val, int lastKey)
{
int inc = 1; // vu is DataGridView
If (val == 33) inc = -1;
int rowsDisp = vu.RowShow; // # of rows displayed
int rowsMax = vu.RowCount; // # of rows in view
int rows = 0;
switch (lastKey)
{
case 17: // Ctrl prior to Page
rows = inc;
break;
case 19: // Alt prior to Page
rows = rowsMax * inc;
break;
default:
rows = rowsDisp * inc
break;
} // end switch
vu.PageMove(rows)
} // end Page_Key
'----- Calling Program B4PPC, VB -----
Sub Page_Key(val,lastKey) ' 33=PageUp, 34=Down
inc = 1 ' vu is DataGridView
If val = 33 then inc = -1
rowsDisp = vu.RowShow ' # of rows displayed
rowsMax = vu.RowCount ' # of rows in view
rows = 0
Select lastKey
Case 17 ' Ctrl prior to Page
rows = inc
Case 19 ' Alt prior to Page
rows = rowsMax * inc
Case Else
rows = rowsDisp * inc
End Select
lastKey = ""
vu.PageMove(rows)
End Sub
fonte
2013-01-25 17:10:15
possibile duplicato di [DataGridView: Scorrere verso il basso automaticamente solo se il rotolo è in fondo] (http://stackoverflow.com/questions/16263377/datagridview-scroll- down-automatically-only-if-the-scroll-is-at-the-bottom) –