DataRepeater.ScrollItemIntoView 方法 (Int32, Boolean)

将指定的 DataRepeaterItemDataRepeater 控件的视图,可选择对齐其与控件的顶部。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
Public Sub ScrollItemIntoView ( _
    index As Integer, _
    alignWithTop As Boolean _
)
public void ScrollItemIntoView(
    int index,
    bool alignWithTop
)
public:
void ScrollItemIntoView(
    int index, 
    bool alignWithTop
)
member ScrollItemIntoView : 
        index:int * 
        alignWithTop:bool -> unit 
public function ScrollItemIntoView(
    index : int, 
    alignWithTop : boolean
)

参数

异常

异常 条件
ArgumentOutOfRangeException

为 index 指定的值小于 0 或大于 ItemCount - 1。

备注

调用 ScrollItemIntoView 方法显示控件的可见部分的特定 DataRepeaterItem 。该项不会选择。若要选择该项,请设置 CurrentItemIndex 属性。

若要使该项目的顶级与控件的顶部,请将 alignWithTop 参数传递给 true。如果 alignWithTop 是 false,项目将滚入视图由一个最小滚动算法;它不一定对齐与控件的顶部。

示例

下面的代码示例演示如何创建第一个突出显示的项。 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 安全性

请参见

参考

DataRepeater 类

ScrollItemIntoView 重载

Microsoft.VisualBasic.PowerPacks 命名空间

CurrentItemIndex

FirstDisplayedItemIndex

其他资源

DataRepeater 控件简介 (Visual Studio)

如何:在 DataRepeater 控件中搜索数据 (Visual Studio)