473,465 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrids (again)

Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.

Jul 19 '06 #1
6 981
Mike,

I have given you an aswer on this standard question some days ago in this
newsgroup.

Cor

<mf********@yahoo.caschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.

Jul 19 '06 #2
Hi Cor.

Actually the last datagrid post I did was concerning visual controls
that were not in the grid but were pointing to the same record. The
solution was to call EndCurrentEdit of the currencymanager which fixed
the problem.

This issue involves changes that are done within a cell in a grid.
User enters data in the cell, never tabbing to the next cell, and then
quits the app which triggers saving to the db. The changes are not
saved. I tried calling EndCurrentEdit but that did not fix the
problem.

Thanks!

Cor Ligthert [MVP] wrote:
Mike,

I have given you an aswer on this standard question some days ago in this
newsgroup.

Cor

<mf********@yahoo.caschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.
Jul 19 '06 #3
so,

if i understand correctly, the user makes changes in a cell ... than exits
the application - presses the close button on the window control bar ... the
data is not changed in the dataadapter because the cell did not lose focus
and the change is not ackonwledged ...

in the closing event, get the current cell with focus and set the focus to
the next cell ... force a tab or something ... or set focus to another
control on the window ... anything to move the cursor / focus out of the
curent cell ... this should force the data change to be acknowledge and the
EndCurrentEdit should work...and thus the update to save the data ...

<mf********@yahoo.cawrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi Cor.

Actually the last datagrid post I did was concerning visual controls
that were not in the grid but were pointing to the same record. The
solution was to call EndCurrentEdit of the currencymanager which fixed
the problem.

This issue involves changes that are done within a cell in a grid.
User enters data in the cell, never tabbing to the next cell, and then
quits the app which triggers saving to the db. The changes are not
saved. I tried calling EndCurrentEdit but that did not fix the
problem.

Thanks!

Cor Ligthert [MVP] wrote:
>Mike,

I have given you an aswer on this standard question some days ago in this
newsgroup.

Cor

<mf********@yahoo.caschreef in bericht
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.

Jul 19 '06 #4
On validating of the grid control throw a boolean variable "IsDirty"
and on closing of the form:

If IsDirty then
If MsgBox("You have unsaved changes. Would you like to save your
changes now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then e.Cancel =
True
End If

jeff wrote:
so,

if i understand correctly, the user makes changes in a cell ... than exits
the application - presses the close button on the window control bar ... the
data is not changed in the dataadapter because the cell did not lose focus
and the change is not ackonwledged ...

in the closing event, get the current cell with focus and set the focus to
the next cell ... force a tab or something ... or set focus to another
control on the window ... anything to move the cursor / focus out of the
curent cell ... this should force the data change to be acknowledge and the
EndCurrentEdit should work...and thus the update to save the data ...

<mf********@yahoo.cawrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi Cor.

Actually the last datagrid post I did was concerning visual controls
that were not in the grid but were pointing to the same record. The
solution was to call EndCurrentEdit of the currencymanager which fixed
the problem.

This issue involves changes that are done within a cell in a grid.
User enters data in the cell, never tabbing to the next cell, and then
quits the app which triggers saving to the db. The changes are not
saved. I tried calling EndCurrentEdit but that did not fix the
problem.

Thanks!

Cor Ligthert [MVP] wrote:
Mike,

I have given you an aswer on this standard question some days ago in this
newsgroup.

Cor

<mf********@yahoo.caschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.
Jul 19 '06 #5
Mike,

Simple,

Don't start with this, a datagrid has in front a little pencil to
acknowledge the editing, so let the user do that. You are now building an
application that is not working confirm the standards of that control.

Just my thought,

Cor

<mf********@yahoo.caschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.

Jul 20 '06 #6
Have you stepped through to see if the .HasChanges is returning as true?
I'm guessing here, but maybe the change to the cell in the datagrid isn't
making the change to the DataSet until after the cell loses focus.

Also I don't think the .AcceptChanges is necessary as calling the
DataAdapter.Update should set all rowstates to unchanged.

<mf********@yahoo.cawrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi.

A scenario has come up in which I'm not sure how to handle. What is
happening is the user enters information in a cell of the grid. If the
user then quits the application as soon as he finishes entering the
data, the data entered in the cell is not saved. I have the following
code in the closing event of the form:

If DataSet.HasChanges Then
Try
DataAdapter.Update(DataSet.GetChanges, "Table")
DataSet.AcceptChanges()
Catch e As Exception
MsgBox(e.message)
Exit Sub
End Try
End If

However, if the user tabs to the next cell, the data is saved. Is
there something that can be done to save the data without having to
tell the users that they must tab from the cell upon entering data? I
tried replicating a tab key press (SendKeys.Send("{Tab}")) before
updating but this did not fix it.

Thanks a lot for the past and future help!

Mike.

Jul 20 '06 #7

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

Similar topics

2
by: melanieab | last post by:
Hi, Ok, I'm on my own in learning c# for work here and have come pretty far, but I'm confused by all the options available for datagrids. I have a private datagrid (dg), private dataset (ds), and...
0
by: Kathy Burke | last post by:
Hi again. I finally figured out WHAT I need, but not much of a clue how to do it. I'm new to datagrids and I'm using a document-like xml structure versus a database-like structure. I think I need...
2
by: Philip Rayne | last post by:
I have 2 datagrids, both with databound columns that I have dynamically added. I have an EditCommandColumn on both grids. EnableViewState is enabled on both of the grids. When I click the edit...
0
by: sJeev via DotNetMonster.com | last post by:
Please help, I am very new to asp.net and data grids have got me stuck for a loooong time. I can either have the right content in my datagrids or make them editable. In the first case, I make...
4
by: ree32 | last post by:
I have a placeholder and depending on a user input(a drop downlist) when the user clicks a button I dynamically create a number of datagrids and fill them with data from a database. But the problem...
3
by: John Jasobs | last post by:
I know this has been asked before but I have not seen it answered. How would one implement nested datagrids in windows forms based on the table relationships within a dataset? Or, is there some...
6
by: Steve Hershoff | last post by:
Hi everyone, I've got a strange one here. There are two datagrids on my page, one nested within the other. I'll refer to them as the topmost and secondary datagrids. In the topmost...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
0
by: tshad | last post by:
I remember Radio buttons having problem keeping values in datagrids in VS 2003. To solve the problem I had picked up a use control from Metabuilders (RowSelectorColumn). This worked real well...
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
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
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
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...
0
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...

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.