473,663 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=f alse" 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 2758
Hi elime,

If you run the data through a DataView, you can use the DataView.AllowN ew property to get rid of the New line.
On Sat, 21 May 2005 09:56:48 +0200, elime <el*****@hotmai l.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=f alse" 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 "DefaultVie w" (dataset.defaul tview)
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.defaul tview.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
9130
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 system.windows.forms.dll
0
1989
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 programaticaly the minimum property of the scroll bar to be >0. But i even do not have access to the scroll bars of the grid because the scrollbars are protected. Unhandled Exception:
3
2143
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 getting an event from the AddNewRow()? I would like to make some changes to the row prior to the user typing in the DataGrid. Thanks,
1
6633
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 the same column header again doesn't change anything, although clicking a different column header re-sorts the data in descending order according to whatever's in that column. I'm pretty much at a loss as to how to even start fixing this. Any...
5
2073
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 = oleDbDataAdapter1->Fill(dataSet1); dataGrid1->DataSource = dataSet1->Tables->Item->DefaultView;
3
5676
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
2384
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 system.windows.forms.dll I can't catch this Exception and it only occurs when I
3
4003
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 selects? thanks...
0
1971
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 range of valid values. After I remove the element from the collection I clear the databindings from the data grid and rebind it but as far as I can tell the collection seems to be the right size but for some reason when I
2
4497
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 boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8547
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.