Click here to Skip to main content
15,902,737 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using Attributes to implement "callbacks" Pin
urbane.tiger28-Jan-07 14:08
urbane.tiger28-Jan-07 14:08 
QuestionGood ideas for beginner programming?? Pin
TrooperIronMan23-Jan-07 13:35
TrooperIronMan23-Jan-07 13:35 
AnswerRe: Good ideas for beginner programming?? Pin
urbane.tiger23-Jan-07 14:04
urbane.tiger23-Jan-07 14:04 
AnswerRe: Good ideas for beginner programming?? Pin
Marc Clifton23-Jan-07 14:36
mvaMarc Clifton23-Jan-07 14:36 
GeneralRe: Good ideas for beginner programming?? Pin
TrooperIronMan24-Jan-07 1:38
TrooperIronMan24-Jan-07 1:38 
Questioncircular references in controls? Pin
amatbrewer23-Jan-07 11:31
amatbrewer23-Jan-07 11:31 
AnswerRe: circular references in controls? Pin
Stefan Troschuetz23-Jan-07 11:52
Stefan Troschuetz23-Jan-07 11:52 
GeneralRe: circular references in controls? Pin
Luc Pattyn23-Jan-07 14:00
sitebuilderLuc Pattyn23-Jan-07 14:00 
The XXXchanged events only fire when the value really changes, assigning a value that is
not different from the current value does not fire the event.

So it all boils down to the question: is my calculation numerically stable, i.e. will
it converge to a single value.

If yes (as with linear transformations, e.g. your unit conversions), dont do anything special.
If no (or unknown), break the loop explicitly (e.g. by removing and reinstalling one of
the event handlers).

The following example has two TextBoxes, showing a number and its square; for some of the
values (e.g. 50) it will take two iterations, but it always reaches a stable result:

public class CPTest_ChangedEvent: CPTest {
    TextBox tb1=new TextBox();
    TextBox tb2=new TextBox();
    System.Windows.Forms.Timer timer=new System.Windows.Forms.Timer();

    public override void Run() {
        tb1.Text="1";
        tb2.Text="1";
        tb1.TextChanged+=new EventHandler(tb1_TextChanged);
        tb2.TextChanged+=new EventHandler(tb2_TextChanged);
        timer.Interval=1000;
        timer.Tick+=new EventHandler(timer_Tick);
        timer.Start();

    }

    private void tb1_TextChanged(object sender, EventArgs e) {
        string s=tb1.Text;
        log("tb1_TextChanged: "+s);
        double i1=double.Parse(s);
        double i2=i1*i1;
        tb2.Text=i2.ToString();
    }

    private void tb2_TextChanged(object sender, EventArgs e) {
        string s=tb2.Text;
        log("tb2_TextChanged: "+s);
        double i2=double.Parse(s);
        double i1=Math.Sqrt(i2);
        tb1.Text=i1.ToString();
    }

    private void timer_Tick(object sender, EventArgs e) {
        string s=tb2.Text;
        double i2=double.Parse(s)+1;
        tb2.Text=i2.ToString();
        if (i2>100) timer.Stop();
    }
}



Smile | :)



Luc Pattyn

GeneralRe: circular references in controls? Pin
aSarafian23-Jan-07 23:05
aSarafian23-Jan-07 23:05 
AnswerRe: circular references in controls? Pin
jayart24-Jan-07 1:28
jayart24-Jan-07 1:28 
QuestionRight Solution in VS.Net? Pin
harjin23-Jan-07 11:31
harjin23-Jan-07 11:31 
AnswerRe: Right Solution in VS.Net? Pin
Christian Graus23-Jan-07 12:41
protectorChristian Graus23-Jan-07 12:41 
QuestionSystem.Timers.Timer Pin
gigo2k623-Jan-07 10:00
gigo2k623-Jan-07 10:00 
AnswerRe: System.Timers.Timer Pin
Christian Graus23-Jan-07 10:29
protectorChristian Graus23-Jan-07 10:29 
GeneralRe: System.Timers.Timer Pin
gigo2k623-Jan-07 10:34
gigo2k623-Jan-07 10:34 
GeneralRe: System.Timers.Timer Pin
Christian Graus23-Jan-07 10:38
protectorChristian Graus23-Jan-07 10:38 
AnswerRe: System.Timers.Timer Pin
Luc Pattyn23-Jan-07 14:07
sitebuilderLuc Pattyn23-Jan-07 14:07 
QuestionWPF frame control, pass options Pin
NikoTanghe23-Jan-07 9:22
NikoTanghe23-Jan-07 9:22 
Questionsearch text in html Pin
nima_dir23-Jan-07 8:39
nima_dir23-Jan-07 8:39 
QuestionPositioning controls on n Physical Screens [modified] Pin
TCHamilton23-Jan-07 7:58
TCHamilton23-Jan-07 7:58 
AnswerRe: Positioning controls on n Physical Screens Pin
Luc Pattyn23-Jan-07 14:17
sitebuilderLuc Pattyn23-Jan-07 14:17 
GeneralRe: Positioning controls on n Physical Screens Pin
TCHamilton24-Jan-07 7:52
TCHamilton24-Jan-07 7:52 
QuestionConfiugration files Pin
peshawarcoder23-Jan-07 7:36
peshawarcoder23-Jan-07 7:36 
AnswerRe: Confiugration files Pin
Bassam Saoud23-Jan-07 9:25
Bassam Saoud23-Jan-07 9:25 
QuestionCOM library stuff Pin
jesarg23-Jan-07 6:54
jesarg23-Jan-07 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.