VB Equivalent

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
 
A

Arne Janning

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
 
C

Cor Ligthert

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
 
W

Wayne Wengert

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
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top