473,782 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to prevent new row in datagrid - prevent new row * icon?

I fill a dataset like this:

dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection
....
da.Fill(ds, "tbl1")
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"

When the form containing datagrid1 displays, all the records are there. The
dataAdapter, da, is based on a stored procedure which only returns a set
number of records from tbl1 on Sql Server. These records are updatable. But
I noticed that there is a new row icon * at the last row of the datagrid. I
can tab into that new row. How can I configure datagrid1 (or the dataset -
whichever) so that when I tab to the end of the last row with data it goes
back to the first row and there is no new row in the datagrid? Is there a
property setting in datagrid1 that I need to set? Or do I just have to write
code? I can see writing code to make it go back to the first record - use
currency manager. But how can I prevent the new row icon * from showing up
in datagrid1?

Thanks,
Rich
Nov 21 '05 #1
4 2505
Hi,

ds.Tables("tbl1 ").defaultview. allownew=false

Ken
----------------------
"Rich" <Ri**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com...
I fill a dataset like this:

dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection
....
da.Fill(ds, "tbl1")
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"

When the form containing datagrid1 displays, all the records are there. The
dataAdapter, da, is based on a stored procedure which only returns a set
number of records from tbl1 on Sql Server. These records are updatable.
But
I noticed that there is a new row icon * at the last row of the datagrid. I
can tab into that new row. How can I configure datagrid1 (or the dataset -
whichever) so that when I tab to the end of the last row with data it goes
back to the first row and there is no new row in the datagrid? Is there a
property setting in datagrid1 that I need to set? Or do I just have to
write
code? I can see writing code to make it go back to the first record - use
currency manager. But how can I prevent the new row icon * from showing up
in datagrid1?

Thanks,
Rich
Nov 21 '05 #2
Thanks very much for your reply. I tried placing your code as follolws:

Private Sub Form1_Load(...)
....
da.Fill(ds, "tbl1")
ds.Tables("tbl1 ").defaultview. allownew=false
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"
--and also tried placing after
ds.Tables("tbl1 ").defaultview. allownew=false

But I still have the ability to add new records. The problem with this is
with the da.UpdateComman d. If I add new records by accident and try to
update the dataset, I get an error, that I need an insert command. Your code
seems logical, but I think I am missing something preliminary to it. Maybe I
need to set a property in the property sheet of the datagrid? I am using a
datagrid control from the toolbox.

Thanks again for your reply.

Rich
"Ken Tucker [MVP]" wrote:
Hi,

ds.Tables("tbl1 ").defaultview. allownew=false

Ken
----------------------
"Rich" <Ri**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com...
I fill a dataset like this:

dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection
....
da.Fill(ds, "tbl1")
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"

When the form containing datagrid1 displays, all the records are there. The
dataAdapter, da, is based on a stored procedure which only returns a set
number of records from tbl1 on Sql Server. These records are updatable.
But
I noticed that there is a new row icon * at the last row of the datagrid. I
can tab into that new row. How can I configure datagrid1 (or the dataset -
whichever) so that when I tab to the end of the last row with data it goes
back to the first row and there is no new row in the datagrid? Is there a
property setting in datagrid1 that I need to set? Or do I just have to
write
code? I can see writing code to make it go back to the first record - use
currency manager. But how can I prevent the new row icon * from showing up
in datagrid1?

Thanks,
Rich

Nov 21 '05 #3
OK. The trick that worked for me was to use a dataview as the datasource for
the datagrid.

Dim dv1 As New Dataview(ds.Tab les("tbl1")
dv1.AllowNew = False
dgr1.Datasource = dv1

Now I don't have the * new record symbol. Your suggestion works perfectly!
Thanks very much for your help.
"Rich" wrote:
Thanks very much for your reply. I tried placing your code as follolws:

Private Sub Form1_Load(...)
...
da.Fill(ds, "tbl1")
ds.Tables("tbl1 ").defaultview. allownew=false
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"
--and also tried placing after
ds.Tables("tbl1 ").defaultview. allownew=false

But I still have the ability to add new records. The problem with this is
with the da.UpdateComman d. If I add new records by accident and try to
update the dataset, I get an error, that I need an insert command. Your code
seems logical, but I think I am missing something preliminary to it. Maybe I
need to set a property in the property sheet of the datagrid? I am using a
datagrid control from the toolbox.

Thanks again for your reply.

Rich
"Ken Tucker [MVP]" wrote:
Hi,

ds.Tables("tbl1 ").defaultview. allownew=false

Ken
----------------------
"Rich" <Ri**@discussio ns.microsoft.co m> wrote in message
news:A5******** *************** ***********@mic rosoft.com...
I fill a dataset like this:

dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection
....
da.Fill(ds, "tbl1")
datagrid1.DataS ource = ds
datagrid1.DataM ember = "tbl1"

When the form containing datagrid1 displays, all the records are there. The
dataAdapter, da, is based on a stored procedure which only returns a set
number of records from tbl1 on Sql Server. These records are updatable.
But
I noticed that there is a new row icon * at the last row of the datagrid. I
can tab into that new row. How can I configure datagrid1 (or the dataset -
whichever) so that when I tab to the end of the last row with data it goes
back to the first row and there is no new row in the datagrid? Is there a
property setting in datagrid1 that I need to set? Or do I just have to
write
code? I can see writing code to make it go back to the first record - use
currency manager. But how can I prevent the new row icon * from showing up
in datagrid1?

Thanks,
Rich

Nov 21 '05 #4
> OK. The trick that worked for me was to use a dataview as the datasource
for
the datagrid.

Dim dv1 As New Dataview(ds.Tab les("tbl1")
dv1.AllowNew = False
dgr1.Datasource = dv1

Now I don't have the * new record symbol. Your suggestion works
perfectly!
Thanks very much for your help.

However the sample that Ken gave you was in my opinion slightly better. And
then of course
\\\
dgr1.Datasource = ds.Tables("tbl1 ").defaultv iew
///
I hope this helps,

Cor
Nov 21 '05 #5

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

Similar topics

2
7546
by: michael walser | last post by:
display checkbox in datagrid. I find that there are 3 status: checked - check box with click icon unchecked - blank in check box unknown - click icon but color in gray..... How can I set the check box only 2 status, checked and unchecked?
0
2271
by: Suzanne | last post by:
I'd like to know how can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key? I have found this code on a windows forms FAQ site : Public Class DataGrid_Custom Inherits DataGrid Private Const WM_KEYDOWN = &H100
0
240
by: Tim::.. | last post by:
Can someone please tell me how I can get the following JavaScript to work inside this datagrid! What I'm trying to do is to have a layer that shows up with an image of an employee when you onMouseOver an icon in the datagrid! Some how I need each icon to have a different id that relates to an image record in a database... At the moment I'm using Active Directory to pull the users details from...
3
1167
by: Engineerik | last post by:
The vb6 datagrid had a "button" property which I used to display a dropdown icon in a cell. I created a popup menu that would display the list of valid choices for that cell when the user clicked the dropdown icon. In vb.net I havn't been able to figure out how to display that little dropdown icon in a datagrid cell. Anybody know how to display the dropdown icon in the datagrid and the best way to display a list of valid entries which the...
14
1842
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid will be used to populate information coming from a Webservice. (No datasets - No datareaders). So, I do not know see how to use the "datasource".
2
5049
by: Olaf Rabbachin | last post by:
Hi folks, I'd like to notify the user that rows within a datagrid require user-interaction/processing. The RowHeader is visible and wide enough so that the exclamation-mark icon as i.e. the ErrorProvider-control displays it would fit in neatly. Is there a way of using the ErrorProvider-control directly or else is there a way of displaying icon in a DataGrid's RowHeaders? Cheers & TIA,
4
1613
by: Pawel | last post by:
Hello I've a problem with DataGrid and Icon. Incons are in DataGrid's cells next to the other data. And now. When i cklick this icon i want to change icon without reload site. How to do this? Below part of code.
0
1428
by: Claire | last post by:
Hi, Visual Studio 2003 The application Im writing is skinned and therefore i need to be able to write my own code for manipulating and drawing headers for a data grid outside of the control. I created and populated a dataset (source at end of mail) and bound it to a grid for testing. For the datagrid, I used a tablestyles object mapped to table "box". I add gridcolumnstyles for each column and set the 'Icon' column width to 32
0
1086
by: prerak_v_shah | last post by:
Hi, Friends, I have been developing datagrid program in .Net 1.1 and having VB.Net as a programming language. I have created a datagrid which is bound to a datatable as its datasource. It also shows two columns and both are having comboboxes as its selection control. Data grid is editable and it allows Add, Delete, Modify functionalities. I have also created event handler to trap any rowchanges (RowChanged event) in the grid. Here I...
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10313
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
10081
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
8968
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
7494
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.