Datagrid insert row removal

  • Thread starter Thread starter Tonya
  • Start date Start date
T

Tonya

Hi,

I wanted to know how i could get rid of the final row that
appears in a datagrid (The one where a new row can be
entered).

can anyone point me in the right direction??

thx in advance
 
Hi Miha,

Where do i wright this code?
my datasourse is a dataset that i created.
do i just do

dataset.ibindinglist.allownew=false
??

here ismt datagrid tht is being created....

da = New SqlDataAdapter("SELECT Meal_Type, 0 as Quantity
FROM Menu", Cn)

ds = New DataSet("MealBooking")
da.Fill(ds, "MealBooking")
DGridMealBooking.DataSource = ds.Tables(0)

Dim TSMealBooking As New DataGridTableStyle()
TSMealBooking.MappingName = "MealBooking"

Dim TCMealName As New DataGridTextBoxColumn()
TCMealName.MappingName = "Meal_Type"
TCMealName.HeaderText = "Meal Name"
TCMealName.Width = 150
TCMealName.ReadOnly = True
TSMealBooking.GridColumnStyles.Add(TCMealName)

Dim TCMealQuantity As New DataGridTextBoxColumn()
TCMealQuantity.MappingName = "Quantity"
TCMealQuantity.HeaderText = "Quantity"
TCMealQuantity.Width = 100
TCMealQuantity.ReadOnly = False
TSMealBooking.GridColumnStyles.Add(TCMealQuantity)

DGridMealBooking.TableStyles.Add(TSMealBooking)


thx for your help :o)
 
Hi Miha,

I have tried this but i keep getting an error stating....
An unhandled exception of type 'System.Exception'
occurred in system.windows.forms.dll
Additional information: Complex DataBinding accepts as a
data source either an IList or an IListSource

the application stops at this line...
DGridMealBooking.DataSource =
ds.Tables(0).DefaultView.AllowNew = False

any ideas on how to resolve this?
 
Hi Miha,

thx for your help. Youve been great. :o)
I have just relised what i was doing wrong.

Thx again

Tonya
 
Back
Top