DataGrid issues

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,

I am using a datagrid on windows form. What I want is that it should allow editing of certain columns but should not allow adding new rows. I have added a table style and the columns to the table style collection but I still get a last row with * allowing the users to add new record.

If I turn the grid into readonly then the user cant modify the columns. Is there any way to block adding new rows or to get rid of the last row with *?

Mark
 
Found a solution at http://www.dotnet247.com/247reference/msgs/15/77606.aspx

I think if you will declare an integer and count the rows and substitute
your intger variable where "10" is located.

There is 10 rows in my Data Grid.
When user tries to go to new row (the asterisk row), 11th row, re-position
the cell to the last row (10th row).

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DataGrid1.CurrentCellChanged

If (DataGrid1.CurrentCell.RowNumber > 10) Then
DataGrid1.CurrentCell = New DataGridCell(10,
DataGrid1.CurrentCell.ColumnNumber) ' Re-position back to 10th row
End If

End Sub

[Original message clipped]

Hi,

I am using a datagrid on windows form. What I want is that it should allow
editing of certain columns but should not allow adding new rows. I have
added a table style and the columns to the table style collection but I
still get a last row with * allowing the users to add new record.

If I turn the grid into readonly then the user cant modify the columns. Is
there any way to block adding new rows or to get rid of the last row with *?

Mark
 
Thanks Jeff.

Your link was very useful and I found the way to disable the new rows by
setting the AllowNew property of the DataView to false.

Regards,

Mark
 
Hi,

Try binding to a dataview instead. The dataview has allownew, allowdelete, and allowedit properties.

Ken
--------------------
Hi,

I am using a datagrid on windows form. What I want is that it should allow editing of certain columns but should not allow adding new rows. I have added a table style and the columns to the table style collection but I still get a last row with * allowing the users to add new record.

If I turn the grid into readonly then the user cant modify the columns. Is there any way to block adding new rows or to get rid of the last row with *?

Mark
 
Back
Top