473,804 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating the state of a control

Often I want to change the Enable or Visibility on a control when some other
control on the form changes. Or maybe I need to make a change to the
DataSource on a combo box when the user makes a selection elsewhere on the
form.

In Visual FoxPro, you would call Refresh on the form causing Refresh to be
called on all the controls on the form, causing the Refresh event code to be
called and allowing the controls to update themselves to the new state. Or
sometime you might just call Refresh on a single control if two controls are
tightly coupled.

Basically, I would like to have a method to call on a form or control that
will execute some event code that I have provided.

I can't find anything in Windows Forms so far that even reminds me of this
capability, yet I expect that this kind of functionality is widely used.
Can someone help me find the right tree in this forest?

Nov 17 '05 #1
4 1535
System.Windows. Forms.Control has an event called "Refresh", is this the
tree you look for.

WinFroms expose a lot of even handler you can hook your code in,are you
looking for how to hook an event handler to call your own code?
Generally, you can override some event handler methods to do the stuff
you are interested.

JW

RL Stevenson wrote:
Often I want to change the Enable or Visibility on a control when some other
control on the form changes. Or maybe I need to make a change to the
DataSource on a combo box when the user makes a selection elsewhere on the
form.

In Visual FoxPro, you would call Refresh on the form causing Refresh to be
called on all the controls on the form, causing the Refresh event code to be
called and allowing the controls to update themselves to the new state. Or
sometime you might just call Refresh on a single control if two controls are
tightly coupled.

Basically, I would like to have a method to call on a form or control that
will execute some event code that I have provided.

I can't find anything in Windows Forms so far that even reminds me of this
capability, yet I expect that this kind of functionality is widely used.
Can someone help me find the right tree in this forest?

Nov 17 '05 #2
Thank you for pointing out the refresh method. I was not looking in the
right place.

Now, how to find out what events, if any, are caused by calling Refresh.

I did a simple experiment with a textbox to see if I could invoke my event
code by calling Refresh. The help file says Refresh causes the control to
redraw itself, but doesn't mention any events that occur.

Hoped to find a Refresh event for a textbox, but no.

Paint event? No such thing for a text box.

Maybe the Layout event?

That one doesn't seem to be triggered by invoking Refresh on the textbox.

Seems like there should be some event that is triggered, but I haven't
discovered it yet.

Any hints?
"Jianwei Sun" <js***********@ gmail.com> wrote in message
news:O$******** ******@TK2MSFTN GP10.phx.gbl...
System.Windows. Forms.Control has an event called "Refresh", is this the
tree you look for.

WinFroms expose a lot of even handler you can hook your code in,are you
looking for how to hook an event handler to call your own code? Generally,
you can override some event handler methods to do the stuff you are
interested.

JW

RL Stevenson wrote:
Often I want to change the Enable or Visibility on a control when some
other control on the form changes. Or maybe I need to make a change to
the DataSource on a combo box when the user makes a selection elsewhere
on the form.

In Visual FoxPro, you would call Refresh on the form causing Refresh to
be called on all the controls on the form, causing the Refresh event code
to be called and allowing the controls to update themselves to the new
state. Or sometime you might just call Refresh on a single control if
two controls are tightly coupled.

Basically, I would like to have a method to call on a form or control
that will execute some event code that I have provided.

I can't find anything in Windows Forms so far that even reminds me of
this capability, yet I expect that this kind of functionality is widely
used. Can someone help me find the right tree in this forest?


Nov 17 '05 #3
Hi,

In c# you don't "Refresh" a control, because in c# their is no distinction
between the control, and it's value. It looks to me as if Foxpro is a bit
like C++/MFC, which kept the controls and values seperate, and the programmer
had to keep them in synch. The way it works in C# is that you just assign a
value to control's property, and that's it, you are done.

eg.
TextBox name = new TextBox();
name.Text = "Jerry Jones";

if (name.Text == "Jerry Jones)...

That's it...no other data to maintain or synchronise.

There is also the problem of changing several controls when one control
changes. I don't know if there is a neat c# solution to that problem. I write
a method called "UpdateControls " which changes the states of the controls
which are dependant on other controls. I invoke "UpdateControls " whenever one
of the controls which is depended on changes value.

Regards,

Stephen
"RL Stevenson" wrote:
Often I want to change the Enable or Visibility on a control when some other
control on the form changes. Or maybe I need to make a change to the
DataSource on a combo box when the user makes a selection elsewhere on the
form.

In Visual FoxPro, you would call Refresh on the form causing Refresh to be
called on all the controls on the form, causing the Refresh event code to be
called and allowing the controls to update themselves to the new state. Or
sometime you might just call Refresh on a single control if two controls are
tightly coupled.

Basically, I would like to have a method to call on a form or control that
will execute some event code that I have provided.

I can't find anything in Windows Forms so far that even reminds me of this
capability, yet I expect that this kind of functionality is widely used.
Can someone help me find the right tree in this forest?

Nov 17 '05 #4
Thanks.

Your approach is very similar to the one I used.

I liked the FoxPro approach because it seemed more object-oriented to me.
The code to update the state of the control is part of the control. You can
consider the control to be an abstract state machine in some sense because
when you tell it to update itself, the control finds the state variables in
its environment that affect it, and then the control changes its state to
conform to the current environment.

"Javaman59" <Ja*******@disc ussions.microso ft.com> wrote in message
news:59******** *************** ***********@mic rosoft.com...
Hi,

In c# you don't "Refresh" a control, because in c# their is no distinction
between the control, and it's value. It looks to me as if Foxpro is a bit
like C++/MFC, which kept the controls and values seperate, and the
programmer
had to keep them in synch. The way it works in C# is that you just assign
a
value to control's property, and that's it, you are done.

eg.
TextBox name = new TextBox();
name.Text = "Jerry Jones";

if (name.Text == "Jerry Jones)...

That's it...no other data to maintain or synchronise.

There is also the problem of changing several controls when one control
changes. I don't know if there is a neat c# solution to that problem. I
write
a method called "UpdateControls " which changes the states of the controls
which are dependant on other controls. I invoke "UpdateControls " whenever
one
of the controls which is depended on changes value.

Regards,

Stephen
"RL Stevenson" wrote:
Often I want to change the Enable or Visibility on a control when some
other
control on the form changes. Or maybe I need to make a change to the
DataSource on a combo box when the user makes a selection elsewhere on
the
form.

In Visual FoxPro, you would call Refresh on the form causing Refresh to
be
called on all the controls on the form, causing the Refresh event code to
be
called and allowing the controls to update themselves to the new state.
Or
sometime you might just call Refresh on a single control if two controls
are
tightly coupled.

Basically, I would like to have a method to call on a form or control
that
will execute some event code that I have provided.

I can't find anything in Windows Forms so far that even reminds me of
this
capability, yet I expect that this kind of functionality is widely used.
Can someone help me find the right tree in this forest?

Nov 17 '05 #5

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

Similar topics

3
2786
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with some suitable default values in the tables. I note that although I can script the schema so that re-creating the structure of the database is simple on the users machine, I cannot script the contents of the tables also (automatically). What I would...
5
12534
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I update the datasource - awesome, but I have an issue with updating from a different thread. Here is my datasource, a person class that raises the PropertyChanged event: class Person : INotifyPropertyChanged {
0
1659
by: John Mason | last post by:
Hi, I've been trying for most of the day to get a FormView control to work. I would like to display a single record, based on a unique user id (loginid), which I am retreiving from a cookie. No paging involved. I want to give the user the ability to edit their record and update it (no insert). I pre-populate the database fields with values, and when I execute the page, it wipes out the corresponding database field values belonging to
1
2375
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will need updating with 'CLOSED' where necessary.) I have been trying to use the OLEDB command builder to build the statement to update the database however it is returning an error whenever I try to do this. I already have a dataset full of data, 1...
0
9704
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
9571
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,...
0
10561
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...
1
10302
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,...
1
7608
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
5505
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
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.