Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to clear FileSystemWatcher.Path ? Pin
Johnny J.20-May-10 19:55
professionalJohnny J.20-May-10 19:55 
GeneralMessage Removed Pin
21-May-10 3:34
EthicsGradient21-May-10 3:34 
GeneralRe: How to clear FileSystemWatcher.Path ? Pin
Johnny J.21-May-10 3:38
professionalJohnny J.21-May-10 3:38 
GeneralMessage Removed Pin
21-May-10 13:58
EthicsGradient21-May-10 13:58 
GeneralRe: How to clear FileSystemWatcher.Path ? Pin
Pete O'Hanlon23-May-10 9:11
mvePete O'Hanlon23-May-10 9:11 
QuestionWM_PAINT makes textbox non-unicode Pin
thomus0719-May-10 18:27
thomus0719-May-10 18:27 
AnswerRe: WM_PAINT makes textbox non-unicode Pin
thomus0719-May-10 18:53
thomus0719-May-10 18:53 
QuestionI Find This Baffling Pin
Roger Wright19-May-10 18:16
professionalRoger Wright19-May-10 18:16 
I'm writing a simple flow calculator using <a href="http://www.brighthub.com/engineering/civil/articles/52905.aspx">Manning's Equation</a>[<a href="http://www.brighthub.com/engineering/civil/articles/52905.aspx" target="_blank" title="New Window">^</a>] to determine gravity flow rates in sewer lines. Not for publication, mind you - I'm just tired of having to do it manually with a calculator 50 times a day.

I started a new Windows Form application, added a couple of radio buttons for the user (me) to select the shape of the channel - round, rectangular, or trapezoidal - and created some functions to change the display of the main form according to which shape the user selects. The first two take two parameters, the third, three. It all works perfectly so far, to wit:

<pre> public partial class FlowCalcs : Form
{
private int Shape; //Channel shape
private int Material; //Channel material
private double N; //Manning's coefficient
private double Area; //Area of flow
private double Perimeter; //Wetted perimeter
private double Radius; //Hydraulic radius
private double Slope; //Slope of channel
private double Flow; //Flow velocity, ft/sec
private double Gpm; //Flow volume, gallons per minute

public FlowCalcs()
{
InitializeComponent();

}

private void rbtnRect_CheckedChanged(object sender, EventArgs e)
{
if (rbtnRect.Checked == true)
{
Shape = 2;
lblDh.Text = "Height, h =";
lbldW1.Text = "Width, W =";
lblW2.Visible = false;
txtW2.Visible = false;
txtW2.Enabled = false;
}
}



private void rbtnTrap_CheckedChanged(object sender, EventArgs e)
{
if (rbtnTrap.Checked == true)
{
Shape = 3;
lblDh.Text = "Height, h =";
lbldW1.Text = "Width, W1 =";
lblW2.Text = "Width, W2 =";
lblW2.Visible = true;
lblW2.Enabled = true;
txtW2.Visible = true;
txtW2.Enabled = true;
}
}

private void rbtnRound_CheckedChanged(object sender, EventArgs e)
{
if (rbtnRound.Checked == true)
{
Shape = 1;
lblDh.Text = "Diameter, D =";
lbldW1.Text = "Depth, d =";
lblW2.Text = "";
lblW2.Visible = false;
txtW2.Visible = false;
txtW2.Enabled = false;
}

}</pre>

Then the fun begins. I added a few textboxes to enter the dimensions of the channel, and coded a couple of handlers for the _TextChanged event.

<pre>private void txtDh_TextChanged(object Sender, EventArgs e)
{
testDimensions(Sender,e);
}
private void txtdW1_TextChanged(object Sender, EventArgs e)
{
testDimensions(Sender, e);
}
private void txtW2_TextChanged(object Sender, EventArgs e)
{
testDimensions(Sender, e);
}</pre>

The testDimensions method just checks the length of the text in each textbox to see if a meaningful calculation can be performed yet - a missing entry blocks execution of the numerical calculations. If all the right boxes have numbers in them it converts them to double and does the math.

The goofy bit is that, while the operations on the radio button events work perfectly, typing values into the textboxes never triggers the TextChanged event. Even weirder (is that a word?), when I use the Watch window in the debugger, every variable contained in the main Form is reported as 'does not exist in the current context' or some such wording. Another weirdity (I know that's not a word) is that, when trying to step through the program, each key click advances correctly through the Program.cs file, then it shifts to the Designer file to initialize the Form object. When that's done, my form is displayed, then it moves the cursor back to the Program.cs file, instead of the Form's main page. I haven't seen that happen before, and it confuses me greatly.

Another clue to this mystery: When I enter a value into a textbox while debugging, it makes a 'bonk' sound; when I tab to the next textbox, it doesn't. I don't know what that means, and searching MSDN for 'bonk sound' hasn't been too revealing.

By the way, there are no syntax errors, compilation errors, or runtime errors reported. According to Visual Studio 2008, my program is perfect; it just doesn't do anything. I've been beating this deceased equine for four evenings so far, with no progress. Can someone provide me a clue?

[EDIT]
Now this is odd. I posted this using Opera, and I'm now viewing it with IE7. What got posted was not what I intended viewers to see. The sig line was included in the body of the post, and the code blocks were not encoded correctly. Interesting...
[/EDIT]

"A Journey of a Thousand Rest Stops Begins with a Single Movement"
AnswerRe: I Find This Baffling Pin
Luc Pattyn19-May-10 18:42
sitebuilderLuc Pattyn19-May-10 18:42 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 3:00
professionalRoger Wright20-May-10 3:00 
GeneralRe: I Find This Baffling Pin
Luc Pattyn20-May-10 3:34
sitebuilderLuc Pattyn20-May-10 3:34 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 5:11
professionalRoger Wright20-May-10 5:11 
GeneralRe: I Find This Baffling Pin
Luc Pattyn20-May-10 5:20
sitebuilderLuc Pattyn20-May-10 5:20 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 16:10
professionalRoger Wright20-May-10 16:10 
GeneralRe: I Find This Baffling Pin
Luc Pattyn20-May-10 16:29
sitebuilderLuc Pattyn20-May-10 16:29 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 16:51
professionalRoger Wright20-May-10 16:51 
GeneralRe: I Find This Baffling Pin
Luc Pattyn20-May-10 17:12
sitebuilderLuc Pattyn20-May-10 17:12 
GeneralRe: I Find This Baffling Pin
Luc Pattyn20-May-10 18:08
sitebuilderLuc Pattyn20-May-10 18:08 
GeneralRe: I Find This Baffling Pin
dybs21-May-10 18:35
dybs21-May-10 18:35 
AnswerRe: I Find This Baffling Pin
dybs19-May-10 18:44
dybs19-May-10 18:44 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 3:02
professionalRoger Wright20-May-10 3:02 
GeneralRe: I Find This Baffling Pin
Roger Wright20-May-10 16:17
professionalRoger Wright20-May-10 16:17 
QuestionHttpWebRequest simultaneously!!!! Pin
Christian_V_V19-May-10 18:05
Christian_V_V19-May-10 18:05 
AnswerRe: HttpWebRequest simultaneously!!!! Pin
Luc Pattyn19-May-10 18:45
sitebuilderLuc Pattyn19-May-10 18:45 
AnswerRe: HttpWebRequest simultaneously!!!! Pin
Jens Meyer19-May-10 19:03
Jens Meyer19-May-10 19:03 

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.