Share via


ControlBindingsCollection.RemoveAt 方法

删除指定索引处的 Binding

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Sub RemoveAt ( _
    index As Integer _
)
用法
Dim instance As ControlBindingsCollection
Dim index As Integer

instance.RemoveAt(index)
public void RemoveAt (
    int index
)
public:
void RemoveAt (
    int index
)
public void RemoveAt (
    int index
)
public function RemoveAt (
    index : int
)

参数

  • index
    从零开始的索引(属于要移除的项)。

异常

异常类型 条件

ArgumentOutOfRangeException

index 值小于 0 或大于集合中的绑定数。

备注

如果移除成功,则发生 CollectionChanged 事件。

示例

下面的代码示例使用 Count 属性来确定索引是否在集合的范围之内。如果是这样,则移除第三个 Binding

Private Sub RemoveThirdBinding()
    If textBox1.DataBindings.Count < 3 Then
        Return
    End If
    textBox1.DataBindings.RemoveAt(2)
End Sub
private void RemoveThirdBinding()
{
   if(textBox1.DataBindings.Count < 3) return;
   textBox1.DataBindings.RemoveAt(2);
}
private:
   void RemoveThirdBinding()
   {
      if ( textBox1->DataBindings->Count < 3 )
      {
         return;
      }
      textBox1->DataBindings->RemoveAt( 2 );
   }
private void RemoveThirdBinding()
{
    if (textBox1.get_DataBindings().get_Count() < 3) {
        return ;
    }
    textBox1.get_DataBindings().RemoveAt(2);
} //RemoveThirdBinding

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ControlBindingsCollection 类
ControlBindingsCollection 成员
System.Windows.Forms 命名空间