473,888 Members | 1,475 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 1853
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
6741
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
1924
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
1872
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
1022
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
2121
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
1311
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
1333
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
2098
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
1992
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
11180
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...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
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
9597
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 projectplanning, coding, testing, and deploymentwithout 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
7990
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
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5817
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
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4244
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.