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

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.DataSource = ds
datagrid1.DataMember = "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 2488
Hi,

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

Ken
----------------------
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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.DataSource = ds
datagrid1.DataMember = "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.DataSource = ds
datagrid1.DataMember = "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.UpdateCommand. 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**@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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.DataSource = ds
datagrid1.DataMember = "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.Tables("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.DataSource = ds
datagrid1.DataMember = "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.UpdateCommand. 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**@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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.DataSource = ds
datagrid1.DataMember = "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.Tables("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").defaultview
///
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
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...
0
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...
0
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...
3
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...
14
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...
2
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...
4
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?...
0
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...
0
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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,...
0
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...

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.