473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataGrid issues

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

Nov 20 '05 #1
3 2246
Found a solution at http://www.dotnet247.com/247referenc.../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

"Allan Wong" <bu***@singnet.com.sg> wrote in message
news:ODKQ3QG3BHA.1940@tkmsftngp05...
[Original message clipped]

"Mark" <ma***@dynatechsolutions.com> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
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
Nov 20 '05 #2
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

"Jeff Brown" <no******@thistime.com> wrote in message
news:0r*****************@twister.austin.rr.com...
Found a solution at http://www.dotnet247.com/247referenc.../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

"Allan Wong" <bu***@singnet.com.sg> wrote in message
news:ODKQ3QG3BHA.1940@tkmsftngp05...
[Original message clipped]

"Mark" <ma***@dynatechsolutions.com> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #3
Hi,

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

Ken
--------------------
"Mark" <ma***@dynatechsolutions.com> wrote in message news:O9**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes,...
5
by: ManuNeko | last post by:
Can anyone tell me how to work with a datagrid or where I can find a tutorial or an example? I have a datagrid on my form and now if a user adds a row I want to insert that row into the...
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
20
by: Peter | last post by:
I have the following Class, but I would like to make one of the columns in my DataGrid editable, how would I do that? When I use this class none of the columns are editable even when I set the...
2
by: Hardy Wang | last post by:
Hi all, We have DataGrid control in Web Form, our client requires to be able to click anywhere of a row to fire the event same as LinkBotton column is clicked. We we did in ASP.NET 1.1 is in...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
7
by: GaryDean | last post by:
(one of our developers posted this and it got no answer so I'm giving it another try) I'm converting a DataGrid utility component that previously used the columns array to function as it has in...
2
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
2
by: Mark B | last post by:
I have a Datagrid working fine, outputting: Group Most Popular Product Code -------- ------------------------------- Earth.New Zealand 32 Earth.New Zealand
7
by: Mark B | last post by:
Can someone write some VB.Net example code for me that does this: 1) Creates a gridview control with the results of a SQL stored procedure that has 1 parameter (text) 2) Adds an extra column...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.