Datgrid

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi,

is there away to disable the user clicking on the datagrid row at the bottom
to create a new record , ie at moment if you click the datagrid it allows
edits whihc is ok but how do you dissalow insert from being shown.

Thanks

Neil
 
is there away to disable the user clicking on the datagrid row at the
bottom
to create a new record , ie at moment if you click the datagrid it allows
edits whihc is ok but how do you dissalow insert from being shown.

Make the datagrid read only in the properties menu.
 
Doing that would make it immposible to even edit datagrid ? the problem is I
dont want inserts to appear to happen by a new row being created.

hope thats clear

Thanks
 
Hi,

is there away to disable the user clicking on the datagrid row at the
bottom to create a new record , ie at moment if you click the datagrid
it allows edits whihc is ok but how do you dissalow insert from being
shown.

The specifics depend on exactly what you're binding to, but the way to
do this is to turn off the ability to add new records in your data
source, rather than doing anything to the grid specifically.

Public Sub BindGrid(DataGrid dg, DataTable dt)
dt.DefaultView.AllowNew = False
dg.DataSource = dt
End Sub
 
What you need to do is use a DataView as your grid datasource, and set your
DataView.AllowNew property to false.

The code is something like:


' Assumes you are using a DataTable as the original datasource
Sub SetupGrid(myDataTable as DataTable)
dim myDataView as DataView
myDataView = new DataView(myDataTable)
myDataView.AllowNew = False

myGrid.DataSource = myDataView
End Sub
 
Brilliant yep just what I wanted , managed to get it working in my scenario
Thank you scorpion53061 and also David for replying.

Neil
 
No problem.

You can find solutions like this in the VB.NET/ADO.NET Newsgroup Search Tool
at http://www.kjmsolutions.com/newsgrouptool.htm


Neil said:
Brilliant yep just what I wanted , managed to get it working in my scenario
Thank you scorpion53061 and also David for replying.

Neil

scorpion53061 said:
What you need to do is use a DataView as your grid datasource, and set your
DataView.AllowNew property to false.

The code is something like:


' Assumes you are using a DataTable as the original datasource
Sub SetupGrid(myDataTable as DataTable)
dim myDataView as DataView
myDataView = new DataView(myDataTable)
myDataView.AllowNew = False

myGrid.DataSource = myDataView
End Sub
problem
 
Back
Top