473,324 Members | 2,531 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,324 software developers and data experts.

System.Windows.Forms.DataGrid - dont allow to add new rows! (newby)

Hi all

I load datas from an SQL server to a Datagrid. The datagrid columns are
basically read only but one column is not -> the checkboxcolum. The
user needs to be able to check or uncheck this column for selection.

Now at the end of the datagrid (last row) there is another row with a *
in front of it. Once a user clicks on that, at the position of the
checkboxcolumn, it'll add a new row to the datagrid with NULL values.
You can even add more such NULL-Value-rows by clicking again on the
same position of the new row etc...

Even if nothing can happen (the datacolumns are read only, nothing goes
back to the database) it still looks stupid on the grid. Can I somehow
prevent this? Is there anything like "AllowNewRows=false" or something?

Any help would be great, that row gets on my nerves :(
It doesn't look user-friendly and I need to get to this user-friendly
point with my project (its ad iploma project for my study)

Thanks
Elime

Nov 17 '05 #1
4 2747
Hi elime,

If you run the data through a DataView, you can use the DataView.AllowNew property to get rid of the New line.
On Sat, 21 May 2005 09:56:48 +0200, elime <el*****@hotmail.com> wrote:
Hi all

I load datas from an SQL server to a Datagrid. The datagrid columns are
basically read only but one column is not -> the checkboxcolum. The
user needs to be able to check or uncheck this column for selection.

Now at the end of the datagrid (last row) there is another row with a *
in front of it. Once a user clicks on that, at the position of the
checkboxcolumn, it'll add a new row to the datagrid with NULL values.
You can even add more such NULL-Value-rows by clicking again on the
same position of the new row etc...

Even if nothing can happen (the datacolumns are read only, nothing goes
back to the database) it still looks stupid on the grid. Can I somehow
prevent this? Is there anything like "AllowNewRows=false" or something?

Any help would be great, that row gets on my nerves :(
It doesn't look user-friendly and I need to get to this user-friendly
point with my project (its ad iploma project for my study)

Thanks
Elime


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
Hi Morten!

Thanks for your quick response!!

Unfortunately is the project nearly finished (we are in the
makeup-phase) and we did not set up a DataView-Object for the
databinding. We created SQL-Views but not DataViews and those SQL-Views
are directly loaded into the dataSet which is our DataSource of the
Grid.

As there are many functions in our project that base on that kind of
binding, it would cost a lot of work to re-configure the project to
have a DataView. In fact, it's only a "make-up" change and we decided
to not have this Big change for that.

Is there any other possibility to prevent the adding of new rows
directly in the dataset or the grid?

If not I guess we have to accept it :(

Thanks very much!!
Elime

Nov 17 '05 #3
NO IT'S FINE!! GOT IT!! THANKS A LOT
BIG KISS :)))))

Nov 17 '05 #4
For all that read this and have the same problem:

If you dont work with a seperate dataview-object but want to prohibit
new rows, there is still the possibility of disallow it:

The DataSet has a default-Value "DefaultView" (dataset.defaultview)
which always gives you a dataview of your datatables of the grid. So if
you don't use any special dataview object you can disallow adding new
rows on this default-view:

You can say AllowNew=false (dataset.defaultview.allownew=false) and
your grid will lock the datas.

Nov 17 '05 #5

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

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
0
by: Victor Crudu | last post by:
Hi, could somebody help me to solve the follwing problem ? I get the following exception when i set as the DataSource of a DataGrid a DataTable. This situation can be only if I change...
3
by: max | last post by:
I can generate this error by NOT assigning a tableName to the view: at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit() Is there any possibility of...
1
by: melanieab | last post by:
Hi again, I'm trying to programatically sort a datagrid. I did find the following code, and it does work, but, when a column header is clicked, the data only sorts in descending order. Clicking...
5
by: Sanddevil | last post by:
Hi there - I hope someone out there can help me! I'm using a .Net DataGrid Class to show the results of a SQL query in a spreadsheet type control. The code, which works fine is: iRowCount =...
3
by: Luis Esteban Valencia | last post by:
A page let of work for me I commented almost all lines but nothing the code is this
3
by: mahtan | last post by:
Please help I have the problem that when I change the data in a Windows.Forms.DataGrid by a separate thread the following Exception is thrown: ThreadSystem.NullReferenceException in...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
0
by: Mike | last post by:
Hi, I have a collection object bound to a data grid, after I remove an item from the collection, the minute I click on the datagrid I get an error saying the specified argument was out of the...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.