VB Equivalent

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I found some sample C# code that is supposed to prevent displaying the
Append Row (the asterisk) in a datagrid but I can't get it to work in VB.
The general syntax is not accepted by VB. Here is the code I want to adapt:

//no adding of new rows thru dataview...
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];

((DataView)cm.List).AllowNew = false;


Any suggestions appreciated.

Wayne
 
Wayne said:
I found some sample C# code that is supposed to prevent displaying the
Append Row (the asterisk) in a datagrid but I can't get it to work in VB.
The general syntax is not accepted by VB. Here is the code I want to adapt:

//no adding of new rows thru dataview...
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];

((DataView)cm.List).AllowNew = false;


Any suggestions appreciated.

Wayne

Hi Wayne,

Dim cm As CurrencyManager =
CType(Me.BindingContext(dataGrid1.DataSource, dataGrid1.DataMember),
CurrencyManager)

CType(cm.List, DataView).AllowNew = False

Cheers

Arne Janning
 
Hi Wayne,

Normally this is done with one table
dim dv as new dataview(mytable)
dv.allownew = false
datagrid1.datasource = dv

I you have something more complex answer than again.
(doing the datagrid using the dataview gives you more control by instance
when the user is resorting it)

Cor
 
Thanks - that worked fine, I missed adding the CType. I need to do some
reading on the currencymanager stuff.

Wayne

Arne Janning said:
Wayne said:
I found some sample C# code that is supposed to prevent displaying the
Append Row (the asterisk) in a datagrid but I can't get it to work in VB.
The general syntax is not accepted by VB. Here is the code I want to adapt:

//no adding of new rows thru dataview...
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];

((DataView)cm.List).AllowNew = false;


Any suggestions appreciated.

Wayne

Hi Wayne,

Dim cm As CurrencyManager =
CType(Me.BindingContext(dataGrid1.DataSource, dataGrid1.DataMember),
CurrencyManager)

CType(cm.List, DataView).AllowNew = False

Cheers

Arne Janning
 
Hi Wayne,
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];

((DataView)cm.List).AllowNew = false;

It stays however a very difficult way to just make this sentence what it is

DirectCast(DataGrid1.DataSource, DataTable).DefaultView.AllowNew = False

Cor
 
Back
Top