BindingManagerBase.RemoveAt 方法
当在派生类中被重写时,从基础列表中删除指定索引处的行。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public MustOverride Sub RemoveAt ( _
index As Integer _
)
用法
Dim instance As BindingManagerBase
Dim index As Integer
instance.RemoveAt(index)
public abstract void RemoveAt (
int index
)
public:
virtual void RemoveAt (
int index
) abstract
public abstract void RemoveAt (
int index
)
public abstract function RemoveAt (
index : int
)
参数
- index
要删除行的索引。
异常
异常类型 | 条件 |
---|---|
指定的 index 处没有行。 |
备注
RemoveAt 方法依赖基础数据源来确定方法的使用方式。(有关支持的数据源的列表,请参见 Binding 类。)对于实现 IList、IBindingList、ITypedList 的类以及实现 IList 的强类型类,RemoveAt 方法实际上删除基础列表中的行,而不是移除它的内容。
如果基础列表实现 IBindingList 接口,则 AllowRemove 属性必须返回 true。如果基础列表实现 IList 接口,则 IsFixedSize 属性必须返回 false。
示例
Private Sub button1_Click(sender As Object, e As EventArgs)
Try
' Get the 'BindingManagerBase' object.
Dim myBindingManagerBase As BindingManagerBase = BindingContext(myDataTable)
' Remove the selected row from the grid.
myBindingManagerBase.RemoveAt(myBindingManagerBase.Position)
Catch ex As Exception
MessageBox.Show(ex.Source)
MessageBox.Show(ex.Message)
End Try
End Sub 'button1_Click
private void button1_Click(object sender, System.EventArgs e)
{
try
{
// Get the 'BindingManagerBase' object.
BindingManagerBase myBindingManagerBase=BindingContext[myDataTable];
// Remove the selected row from the grid.
myBindingManagerBase.RemoveAt(myBindingManagerBase.Position);
}
catch(Exception ex)
{
MessageBox.Show(ex.Source);
MessageBox.Show(ex.Message);
}
}
void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
try
{
// Get the 'BindingManagerBase' Object*.
BindingManagerBase^ myBindingManagerBase = BindingContext[ myDataTable ];
// Remove the selected row from the grid.
myBindingManagerBase->RemoveAt( myBindingManagerBase->Position );
}
catch ( Exception^ ex )
{
MessageBox::Show( ex->Source );
MessageBox::Show( ex->Message );
}
}
private void button1_Click(Object sender, System.EventArgs e)
{
try {
// Get the 'BindingManagerBase' object.
BindingManagerBase myBindingManagerBase =
get_BindingContext().get_Item(myDataTable);
// Remove the selected row from the grid.
myBindingManagerBase.RemoveAt(myBindingManagerBase.get_Position());
}
catch (System.Exception ex) {
MessageBox.Show(ex.get_Source());
MessageBox.Show(ex.get_Message());
}
} //button1_Click
平台
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
请参见
参考
BindingManagerBase 类
BindingManagerBase 成员
System.Windows.Forms 命名空间
Position
AddNew