Datagrid Question

  • Thread starter Thread starter simchajoy2000
  • Start date Start date
S

simchajoy2000

Hi,

I have a datagrid in a VB.NET form with a set number of rows that the
user is required to fill out. But I don't want to allow the user to
add or delete rows from the datagrid. The only way I have found to do
disable this functionality is to set datagrid.ReadOnly or
datagrid.Locked equal to true - but when I do this, the user isn't
able to change the information in the cells. Is there some way to
disable the add/delete row functionality for the datagrid but leave
the editing functionality intact?

Joy
 
I have a datagrid in a VB.NET form with a set number of rows that the
user is required to fill out. But I don't want to allow the user to
add or delete rows from the datagrid. The only way I have found to do
disable this functionality is to set datagrid.ReadOnly or
datagrid.Locked equal to true - but when I do this, the user isn't
able to change the information in the cells. Is there some way to
disable the add/delete row functionality for the datagrid but leave
the editing functionality intact?

Hi Joy,

have a look at the example given here:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q653q

and add:

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

Cheers

Arne Janning
 
Thank you! But do you have a version of that code in VB.NET?? I am
struggling to convert it from C# to VB.NET.
 
Joy Labadie said:
Thank you! But do you have a version of that code in VB.NET?? I am
struggling to convert it from C# to VB.NET.

Dim connString as String = "Provider=Microsoft.JET.OLEDB.4.0;data
source=C:\northwind.mdb"
Dim sqlString as String = "SELECT * FROM customers"
Dim connection as OleDbConnection = _
new OleDbConnection(connString)
Dim dataAdapter as OleDbDataAdapter = _
new OleDbDataAdapter(sqlString, connection)
Dim ds as DataSet = new DataSet()
dataAdapter.Fill(ds, "customers")
dataGrid1.DataSource = ds.Tables("customers")
Dim cm as CurrencyManager = CType(me.BindingContext( _
dataGrid1.DataSource, dataGrid1.DataMember), _
CurrencyManager)
DirectCast(cm.List, DataView).AllowNew = False
DirectCast(cm.List, DataView).AllowDelete = False

Cheers

Arne Janning
 

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

Back
Top