473,511 Members | 15,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

databinding properties to controls

I have added application settings for a few user options such as
ShowFramerate.
I have a toolstrip with menu checkable menu items and have bound their
checked property to the relevant applicationSetting.

The databinding works as far as initially loading the setting into the
control, but when the controll is changed, the property is not updated, so I
have to add something like...
onCheckedStateChanged:
Properties.Settings.Default.ShowFramerate=new value

....when I was really hoping that the setting was reading the bound property
and not just writing it. That is... I would like that when the checked
property is changed, the setting, bound to the checked state, is updated.
Can this be done for me, or must I add the code myself?

Dec 6 '07 #1
3 2205
App-settings bindings are one-way; if you look at the designer.cs, it
simply reads, i.e.

this.testMenuItem.Checked =
global::WindowsFormsApplication1.Properties.Settin gs.Default.TestSetting;

You would need to wire it differently if you wanted it to write back.
There is no DataBindings property for ToolStripMenuItem. Perhaps
simply hook the CheckedChanged event of all the menu-items to a shared
handler that identifies the menu from the sender and updates
accordingly?

Marc
Dec 6 '07 #2
Perhaps
simply hook the CheckedChanged event of all the menu-items to a shared
handler that identifies the menu from the sender and updates
accordingly?
Yas that would probably be an accetable solution to have one handler with a
switch of the relevant senders. I was just hoping tht with databinding it
would be truely bound so an active change one place would reflect the other.
Thanks for the feedback

Dec 7 '07 #3
I was just hoping tht with databinding it
would be truely bound
If the menu-item supported data-binding, it would be; for example
binding to a regular CheckBox or TextBox would work [it would generate
some DataBindings.Add(...) code].

You can hook it together manually (using PropertyChanged on the
settings, and CheckedChanged on the menu-item), but if you do you need
to be careful to unsubscribe when the form is disposed.

Marc
Dec 7 '07 #4

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

Similar topics

0
980
by: Sam Martin | last post by:
Hi all, I've got some properties in a business component that get bound to controls on a form using ctrl.DataBindings.Add(.....) The properties are, as you'd expect, updated when their bound...
2
2026
by: John | last post by:
Hi, heres a brief description of what I'm trying to do. I have a sql table named colors that looks like this: color_id color_name 1 blue 2 red 3......... and so...
4
4189
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
3
3136
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
0
999
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...
0
3217
by: Steve | last post by:
I'm trying to implement databinding on a composite control and I'm getting an error with the data when I change the DataSource. The first time I set the DataSource and call DataBind() everything...
9
24759
by: J055 | last post by:
Hi I have a very simple configuration of the GridView with paging and sorting. When I do a postback the DataBinding event fires twice - in both the ProcessPostData and PreRender stages of the...
1
14299
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. ...
1
1618
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
7
13517
by: JTC^..^ | last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox on a windows form the value is reset when I leave the combobox. The comboboxes contain the correct Text and Values. I know...
0
7242
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
7138
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
7353
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
7418
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...
1
7075
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...
1
5063
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
3222
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...
0
1572
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 ...
1
781
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.