本文整理匯總了C#中System.Windows.Forms.DataGridView.DisplayedRowCount方法的典型用法代碼示例。如果您正苦於以下問題:C# DataGridView.DisplayedRowCount方法的具體用法?C# DataGridView.DisplayedRowCount怎麽用?C# DataGridView.DisplayedRowCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.DisplayedRowCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: scrollGrid
private void scrollGrid(DataGridView dataGridView, int index)
{
int halfWay = (dataGridView.DisplayedRowCount(false)/2);
if ((index < 0) && (dataGridView.SelectedRows.Count > 0))
{
index = dataGridView.SelectedRows[0].Index;
}
if (dataGridView.FirstDisplayedScrollingRowIndex + halfWay > index ||
(dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(false)-halfWay) <= index)
{
int targetRow = index;
targetRow = Math.Max(targetRow-halfWay, 0);
try
{
dataGridView.FirstDisplayedScrollingRowIndex = targetRow;
}
catch
{
//soft fail
}
}
}
示例2: SetAktRowVisible
public void SetAktRowVisible(DataGridView gridview, int sorindex)
{
int firstdisprowindex = gridview.FirstDisplayedScrollingRowIndex;
if (firstdisprowindex == -1)
firstdisprowindex = 0;
if (sorindex != -1 && firstdisprowindex > sorindex)
gridview.FirstDisplayedScrollingRowIndex = sorindex;
else
{
int rowcount = gridview.DisplayedRowCount(false);
int teljesrowcount = gridview.DisplayedRowCount(true);
int lastvisible = rowcount + firstdisprowindex;
int teljeslastvisible = teljesrowcount + firstdisprowindex;
if (lastvisible < sorindex && firstdisprowindex < sorindex)
gridview.FirstDisplayedScrollingRowIndex = sorindex;
else
{
if (lastvisible == sorindex)
gridview.FirstDisplayedScrollingRowIndex++;
else if (teljeslastvisible == sorindex)
gridview.FirstDisplayedScrollingRowIndex = gridview.FirstDisplayedScrollingRowIndex + 2;
}
}
}
示例3: HandleGridScrolling
private void HandleGridScrolling(bool Up, DataGridView Grid)
{
// Makes sure the selected row is visible
int VisibleRows = Grid.DisplayedRowCount(false);
int FirstVisibleRow = Grid.FirstDisplayedCell.RowIndex;
int LastVisibleRow = (FirstVisibleRow + VisibleRows) - 1;
int SelectedRow = Grid.CurrentCell.RowIndex;
if (VisibleRows >= Grid.RowCount)
{
return;
}
if (Up)
{
if (FirstVisibleRow == 0)
{
return;
}
if (SelectedRow < FirstVisibleRow + 2)
{
if (SelectedRow > 2)
{
Grid.FirstDisplayedScrollingRowIndex = SelectedRow - 2;
}
else
{
Grid.FirstDisplayedScrollingRowIndex = 0;
}
}
}
else
{
if (LastVisibleRow == Grid.RowCount)
{
return;
}
if (SelectedRow > LastVisibleRow - 3)
{
if (SelectedRow < Grid.RowCount - 3)
{
Grid.FirstDisplayedScrollingRowIndex = SelectedRow - VisibleRows + 3;
}
else
{
Grid.FirstDisplayedScrollingRowIndex =
Grid.RowCount - VisibleRows;
}
}
}
}