Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid - Edit a Single Column - Don't Allow New Rows 1

Status
Not open for further replies.

RSfromCO

Programmer
May 3, 2002
149
0
0
US
I have a list of 20 items. Each item can have a different price. I want to display the list with prices in a scrolling list that displays the item name, and allows the user to view/edit the price (don't allow the user to edit the item name). The list of items and prices is being read from a database table.

I have it working well with a DataGrid except for one minor issue. When the DataGrid is not in ReadOnly mode (so that the user can edit the price for each item), they can click at the bottom of the datagrid and it creates a new row in the list. I don't want them to be able to create a new row in the list!!! If I make the DataGrid ReadOnly, then they loose the capability to edit the price.

This is a Windows Forms DataGrid, not a Web form.

Any suggestions ?
 
Hy,
Maybe this method is trivial for you but I think it will work.
Check if the user added a new record and discard this record.
You can still accept the other changes made by the user.
You can check the rowstate property for: added or modified.
Call AcceptChanges or RejectChanges as you wish for a particualar row.
by
dann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top