preserve datarow number

  • Thread starter Thread starter Strahimir Antoljak
  • Start date Start date
S

Strahimir Antoljak

When a user types in values in last
row of DataGrid, new row is
automatically added below.
In certain cases I would like
to preserve constant number
of rows and prevent a new
row to be automatically added
at the bottom. Is this possible/how?
 
Hi,

Create a dataview from your data. Bind the dataview to the datagrid.
The dataview has an allownew property.

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim dv As DataView

Dim cm As CurrencyManager

Dim iRow As Integer

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn += "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * from Orders", conn)

da.Fill(ds, "Customers")

dv = New DataView(ds.Tables("Customers"))

DataGrid1.DataSource = dv

dv.AllowNew = False

Ken
 
Ken,
you are irreplaceable,
much obliged for your
prompt and accurate
response!
--
Strah @ Langan

Ken Tucker said:
Hi,

Create a dataview from your data. Bind the dataview to the datagrid.
The dataview has an allownew property.

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim dv As DataView

Dim cm As CurrencyManager

Dim iRow As Integer

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn += "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * from Orders", conn)

da.Fill(ds, "Customers")

dv = New DataView(ds.Tables("Customers"))

DataGrid1.DataSource = dv

dv.AllowNew = False

Ken
---------------------
 
Back
Top