本文整理汇总了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;
}
}
}
}