473,624 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding not working when accessing Toolbar

Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.

I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry when saving.
I am able to use the following code to get round the updating of the object from the field value with this code before saving

Private m_Record As Customer

.......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles TopToolBar.Tool Click

'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field before saving.

Has anyone got an elequent way of successfully validating and binding a value before pressing the save button on a toolbar.

Thank you in advance

Stewart
Nov 20 '05 #1
5 1842
Hi Stewart,

The value doesn’t get selected until you hit the Enter key or the TextBox control loses focus. The TextBox doesn’t lose focus when you hit the save button in a control that doesn’t take the focus like a toolbar. You would need to call the Focus method of the Toolbar that has been clicked to force the selection of the new value.

HTH,

Michael
"Stewart" <St*****@discus sions.microsoft .com> wrote in message news:27******** *************** ***********@mic rosoft.com...
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.

I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry when saving.
I am able to use the following code to get round the updating of the object from the field value with this code before saving

Private m_Record As Customer

......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles TopToolBar.Tool Click

'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field before saving.

Has anyone got an elequent way of successfully validating and binding a value before pressing the save button on a toolbar.

Thank you in advance

Stewart

Nov 20 '05 #2
Stewart,

If you have the entire contents in memory you can save it to a temporary
file and load XML. If you have each individual values then you can use the
Automation to populate the values in to the Excel worksheet.

Best Regards,
Y. Sivaram

"Stewart" <St*****@discus sions.microsoft .com> wrote in message
news:27******** *************** ***********@mic rosoft.com...
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.
I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry
when saving. I am able to use the following code to get round the updating of the object from the field value with this code before saving
Private m_Record As Customer

......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles
TopToolBar.Tool Click
'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field before saving.
Has anyone got an elequent way of successfully validating and binding a value before pressing the save button on a toolbar.
Thank you in advance

Stewart

Nov 20 '05 #3
Oops. Sorry posted for the wrong thread!

Best Regards
Y. Sivaram

"Y. Sivaram" <ys******@remov e.this.for.spam .yahoo.com> wrote in message
news:ej******** ******@TK2MSFTN GP10.phx.gbl...
Stewart,

If you have the entire contents in memory you can save it to a temporary
file and load XML. If you have each individual values then you can use the
Automation to populate the values in to the Excel worksheet.

Best Regards,
Y. Sivaram

"Stewart" <St*****@discus sions.microsoft .com> wrote in message
news:27******** *************** ***********@mic rosoft.com...
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.

I have found that when clicking on the Toolbar the focus in the binded

text box does not leave. Therefore in this case not saving the last entry
when saving.
I am able to use the following code to get round the updating of the

object from the field value with this code before saving

Private m_Record As Customer

......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e

As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles
TopToolBar.Tool Click

'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field
before saving.

Has anyone got an elequent way of successfully validating and binding a

value before pressing the save button on a toolbar.

Thank you in advance

Stewart


Nov 20 '05 #4
OK Stewart,

** You use a 3rd-party Control, namely Infragistics. So normally you would pop the question there..... **

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles TopToolBar.Tool Click
TopToolBar.Focu s()

' Your code
............... .
End Sub

Doing so Forces the TextBox to Raise the Validating (and ultimatly Validated) Event. This is, of course, for TextBoxBase-Derived TexBoxes. I don't know what Infragistics uses, but I gues they Derived from TbBase.

If you Trigger your Validation-Code through the TextBox.Validat ing-Event, then this Has to work.

.......

Unless I misunderstood your issue.

Regards,

Michael

"Stewart" <St*****@discus sions.microsoft .com> wrote in message news:C1******** *************** ***********@mic rosoft.com...
Unfortunately I cannot seem to get focus to the toolbar plus the damage has been done. I have clicked the save button, I will have no way of knowing if the validation was correct before carrying on to save the record.

The only way I can see of doing it is to decouple the code from the validating event. Do a select case on the active control name and fire the validating code to know if to proceed or not. I find this would be quirkie would welcome any ideas.


Thanks

Stewart

"Michael Maes" wrote:
Hi Stewart,

The value doesn’t get selected until you hit the Enter key or the TextBox control loses focus. The TextBox doesn’t lose focus when you hit the save button in a control that doesn’t take the focus like a toolbar. You would need to call the Focus method of the Toolbar that has been clicked to force the selection of the new value.

HTH,

Michael


"Stewart" <St*****@discus sions.microsoft .com> wrote in message news:27******** *************** ***********@mic rosoft.com...
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.

I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry when saving.
I am able to use the following code to get round the updating of the object from the field value with this code before saving

Private m_Record As Customer

......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles TopToolBar.Tool Click

'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field before saving.

Has anyone got an elequent way of successfully validating and binding a value before pressing the save button on a toolbar.

Thank you in advance

Stewart

Nov 20 '05 #5
Stewart,
You can use Form.Validate (inherited from ContainerContro l) to valid the
"last invalidated control and its ancestors up through, but not including,
the current control".
Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles
TopToolBar.Tool Click If Me.Validate Then
'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)
End If

End Sub
I got the following tip from "Windows Forms Programming in C#" by Chris
Sells, from Addison Wesley.

Within your "Accept" button click handler ("save" button) process each
control that CausesValidatio n to ensure that they are all valid...

Something like:

For Each control As control In Me.Controls
If control.CausesV alidation Then
control.Focus()
If Not Me.Validate() Then
Me.DialogResult = DialogResult.No ne
Exit For
End If
End If
Next

Note this version does not validate controls nested within other container
controls, such as GroupBoxes...

Hope this helps
Jay

"Stewart" <St*****@discus sions.microsoft .com> wrote in message
news:27******** *************** ***********@mic rosoft.com... Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box.
I have found that when clicking on the Toolbar the focus in the binded text box does not leave. Therefore in this case not saving the last entry
when saving. I am able to use the following code to get round the updating of the object from the field value with this code before saving
Private m_Record As Customer

......

Private Sub TopToolBar_Tool Click(ByVal sender As System.Object, ByVal e As Infragistics.Wi n.UltraWinToolb ars.ToolClickEv entArgs) Handles
TopToolBar.Tool Click
'Ensure last value has been placed into the object
Me.BindingConte xt(m_Record).En dCurrentEdit()

SetCustomer(m_R ecord)

End Sub

however my validating method on the field needs to run on the field before saving.
Has anyone got an elequent way of successfully validating and binding a value before pressing the save button on a toolbar.
Thank you in advance

Stewart

Nov 20 '05 #6

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

Similar topics

6
6728
by: eye5600 | last post by:
Is there a cure for the problems using databinding with a DateTimePicker? I find that a) sometimes it works, sometimes it doesn't, and b) it fails silently causing all databinding on the DataSet to fail with a error message. Help!
8
1909
by: Jeff | last post by:
Hi - I'm having trouble Databinding a SQLDataReader to a DataGrid control. I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in a directory of my localhost on my development machine. The database is on the web. When I run the app on the local machine, IE opens, loads my aspx page from localhost, and hangs. (Eventually I get a page cannot be displayed error.)
3
1852
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were automatically generated, and the objectdatasource let you design against a business object through the gui. Now I am working on my first real web application on 2.0, and I find this automatic functionality doesn't do much beyond allowing me to generate...
0
1005
by: Michael | last post by:
Hi everyone, I'm working on cutting down code in a form I'm working on, and decided to bind the controls to a dataset. I have two problems now. I have a couple datasets that I'm binding to. 1. I have all databinding properties set for the control. When I fill the dataset, there is now data showing up in the control. I'm using this code to load the dataset: With daIndTreatPlan1.SelectCommand.Parameters .Item("@PatientId").Value =...
9
2094
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a form, have the user fill it out then put the data into a class representing a data row and then use the OLEadaptor or OLECommands to update the database. My question is has anyone really used databinding in anything but the simpliest application...
0
1302
by: Andrew Ducker | last post by:
Am I right in thinking that databinding only really takes effect when a control is made visible? The reason I ask is that the application I'm working on consists of a collection of Panels, each of which shows nothing but a "please wait" message until the business service it depends on returns. When it has returned it fills in the panel's controls, and they each make a note of their initial values (so that the form can tell if any...
0
1321
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer" InsertMethod="InsertCustomer" OnUpdated="ObjectDataSource1_Updated" UpdateMethod="UpdateCustomer" OnSelected="ObjectDataSource1_Selected">
8
2082
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the generic type Field<T> (see sample code). public class Employee { public Field<stringForename
3
1986
by: Martin Frey | last post by:
Hello guys, im new to asp.net and im trying to get me used to it. I've managed to create webpages with detailviews, databinding and datasources. Adding or inserting data went very well and, after a while, very fast. Now i ran into a problem with accessing the data. I need to send an email to the administrator with the data the user has selected instead of calling the update method. Everything i've build up via the designer or the...
0
8242
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
8177
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,...
1
8341
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
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
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
6112
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
4084
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
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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

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.