473,394 Members | 1,797 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,394 software developers and data experts.

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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles TopToolBar.ToolClick

'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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 1826
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*****@discussions.microsoft.com> wrote in message news:27**********************************@microsof t.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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles TopToolBar.ToolClick

'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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*****@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles
TopToolBar.ToolClick
'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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******@remove.this.for.spam.yahoo.com> wrote in message
news:ej**************@TK2MSFTNGP10.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*****@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.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_ToolClick(ByVal sender As System.Object, ByVal e

As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles
TopToolBar.ToolClick

'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles TopToolBar.ToolClick
TopToolBar.Focus()

' 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.Validating-Event, then this Has to work.

.......

Unless I misunderstood your issue.

Regards,

Michael

"Stewart" <St*****@discussions.microsoft.com> wrote in message news:C1**********************************@microsof t.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*****@discussions.microsoft.com> wrote in message news:27**********************************@microsof t.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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles TopToolBar.ToolClick

'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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 ContainerControl) to valid the
"last invalidated control and its ancestors up through, but not including,
the current control".
Private Sub TopToolBar_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles
TopToolBar.ToolClick If Me.Validate Then
'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)
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 CausesValidation to ensure that they are all valid...

Something like:

For Each control As control In Me.Controls
If control.CausesValidation Then
control.Focus()
If Not Me.Validate() Then
Me.DialogResult = DialogResult.None
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*****@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.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_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventAr gs) Handles
TopToolBar.ToolClick
'Ensure last value has been placed into the object
Me.BindingContext(m_Record).EndCurrentEdit()

SetCustomer(m_Record)

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
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...
8
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...
3
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...
0
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...
9
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...
0
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...
0
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer"...
8
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...
3
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.