将指定的 DataRepeaterItem 到 DataRepeater 控件的视图。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
Public Sub ScrollItemIntoView ( _
index As Integer _
)
public void ScrollItemIntoView(
int index
)
public:
void ScrollItemIntoView(
int index
)
member ScrollItemIntoView :
index:int -> unit
public function ScrollItemIntoView(
index : int
)
参数
- index
类型:System.Int32
DataRepeaterItem 的索引。
异常
| 异常 | 条件 |
|---|---|
| ArgumentOutOfRangeException | 为 index 指定的值小于 0 或大于 ItemCount - 1。 |
备注
调用 ScrollItemIntoView 方法显示控件的可见部分的特定 DataRepeaterItem 。该项不会选择。若要选择该项,请设置 CurrentItemIndex 属性。
该项目将滚入视图由一个最小滚动算法;它不一定对齐与控件的顶部。若要使该项与控件的顶部,调用与 alignWithTop 参数的重载 ScrollItemIntoView 方法设置为 true。
示例
下面的代码示例演示如何创建第一个突出显示的项。 DataRepeater 控件的当前选定项。它,假设您具有包含一个 DataRepeater 控件 DataRepeater1 的、名为 SynchButton的一个 Button 控件的窗体。
Private Sub SynchButton_Click() Handles SynchButton.Click
' If the first displayed item is not the current item.
If DataRepeater1.FirstDisplayedItemIndex <>
DataRepeater1.CurrentItemIndex Then
' Make it the current item.
DataRepeater1.CurrentItemIndex =
DataRepeater1.FirstDisplayedItemIndex
' Align it with the top of the control.
DataRepeater1.ScrollItemIntoView(
DataRepeater1.FirstDisplayedItemIndex, True)
End If
End Sub
private void synchButton_Click(System.Object sender, System.EventArgs e)
{
// If the first displayed item is not the current item.
if (dataRepeater1.FirstDisplayedItemIndex != dataRepeater1.CurrentItemIndex)
// Make it the current item.
{
dataRepeater1.CurrentItemIndex = dataRepeater1.FirstDisplayedItemIndex;
// Align it with the top of the control.
dataRepeater1.ScrollItemIntoView(dataRepeater1.FirstDisplayedItemIndex, true);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间