|
A problem with this is that if I close the first form that opens, it closes all subsequent ones.
|
|
|
|
|
I assume you mean "When I close the main form, all the other forms close."
Well yes. When you close the main form, the program terminates. This closes all the other forms. Look at the Main method in program.cs
If you have a pump form as your main form, then when that is closed, your app terminates.
Best solution: Don't make the pump form your main form. Have a fuel station form which opens all the pump forms. When you close the fuel station form, the app terminates.
Other solutions are rather more complex.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
I see the Force is with you today.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Use UserControls and TabPages instead of multiple forms?
|
|
|
|
|
Hi,
I want to fill the 2nd combobox with values dependent on the value from the first combobox
In reallife: The first combo contains car brands, the second a list of types. I want that when I select Ford I only get the types from Ford
private void GetVtgMerken()
{
txtBrand.DataSource = _Brand.GetVtgBrand();
txtBran.DisplayMember = "Brand_Name";
txtBran.ValueMember = "Brand_ID";
}
private void GetVtgBrandTypes(int ID)
{
txtType.DataSource = _Brandtype.GetVtgBrandTypes(ID);
txtType.DisplayMember = "type_Naam";
txtType.ValueMember = "MT_Id";
}
private void txtBrand_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = txtBrand.SelectedValue.ToString();
int ID = Convert.ToInt32(txtBrand.SelectedValue.ToString());
int ID = Int32.Parse(txtBrand.SelectedValue.ToString());
GetVtgMerkTypes(ID);
}
When I use Convert.toInt32 or int32.parse I always get the error like below.
System.FormatException: Input string was not in a correct format.
Textbox1.text displays the value correct (ex. 3)
Is there someone who can help ?
|
|
|
|
|
What's the value of txtBrand.SelectedValue.ToString() ? Check if it is really a number (meaning digits only) if it contains letters, you'll need to perform additional formatting or use another container then int for ID.
V.
|
|
|
|
|
When I do:
textBox1.text = txtBrand.SelectedValue.ToString()
the textbox shows the value "3".
An integer I think
But when I convert the textbox to an variable the debugger complains.
Kan een object van het type System.Int32 niet converteren naar het type System.Data.DataRowView.
After a long search i fixt it like this:
private void txtBrand_SelectedIndexChanged(object sender, EventArgs e)
{
if (txtBrand.SelectedValue is DataRowView)
{
string BrandID = Convert.ToInt32(((DataRowView)txtBrand.SelectedValue)["Brand_Id"]).ToString();
int ID = Convert.ToInt32(BrandID);
GetVtgMerkTypes(ID);
}
else
{
int ID = Convert.ToInt32(txtBrand.SelectedValue.ToString());
GetVtgMerkTypes(ID);
}
}
... this works
|
|
|
|
|
conversion methods will throw a FormatException when the input string isn't in the right format, which includes the case where the input is empty. e.g. you may get that while your Form gets loaded. It is often solved easily by including a non-zero-length test in your code.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Luc,
I think you are right !!!
I fixt it with the code below:
private void txtBrand_SelectedIndexChanged(object sender, EventArgs e)
{
if (txtBrand.SelectedValue is DataRowView)
{
string BrandID = Convert.ToInt32(((DataRowView)txtBrand.SelectedValue)["Brand_Id"]).ToString();
int ID = Convert.ToInt32(BrandID);
GetVtgBrandTypes(ID);
}
else
{
int ID = Convert.ToInt32(txtBrand.SelectedValue.ToString());
GetVtgBrandTypes(ID);
}
}
maybe not nice but it works
|
|
|
|
|
|
Translation: Oh crap ive had a bid accepted on rentacoder and I have no clue how to do it.
|
|
|
|
|
which translates back to:
hi,
i have to show a customized message in window media player when videos playing..it is a c# desktop application application...message can be video info author or any customized message by user..advance appreciate for help and advise..
regards
tanzeel;
I hate it when the OP gets removed while holding one or more replies.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi,
i have an existing C# application made in 2005, now we have converted
it into the 2008, now i want to design a from using WPF, and i want to
give it to the 3d look.
So how can i do this?
i am new for WPF.
|
|
|
|
|
A good startup tutorial for WPF 3D is available here.
Based on the size of your older app, this conversion may be a time consuming process.
My signature "sucks" today
|
|
|
|
|
Hello,
I have used
using System.Globalization;
using Excel = Microsoft.Office.Interop.Excel;
in m y project so that I can write my data to excel which works fine when I include the Microsoft object library 12 in my project.
But when I load my program on some other pc the object file 12 is not there with the PC and my code gives errors.
What should be done?
Pritha
|
|
|
|
|
Ive done similar in c++ and it seems that you really need to know which version of excel is on the PC, since it seems to be very hard to do what I would call a 'late bind' to the comm object depending on version.
Does your c# program crash straight away ? The only 100% foolproof way Ive found in c++ is to instanciate the excel object, get the excel version number, and if its not what I expect (ie, when I build the program and imported the type library for excel version x), exit the program gracefully .. I dont know if that helps at all, since I havnt had to use c# yet to do it
'g'
|
|
|
|
|
You can use
using System.Data.SQLClient;
and extract and write data to excel. Just use an excel sql connection string and treat excel like a database.
ConnectionStrings.com is your friend.
|
|
|
|
|
I faced a problem with office 10 when office CDO objects were needed to be installed on a client machine.
This could be something similar to what you are facing here.
My signature "sucks" today
|
|
|
|
|
Peace be upon those who follow true guidance
Hello
This Problem is very easy
You can install Microsoft office in new PC , only .
Because, This library (Microsoft Excel 12.0 object library ) come with Microsoft office 2007 .
Regards
Dr Anas Abbas
|
|
|
|
|
My code for calculating fluid flows in a pipe or channel is working nicely now, except for the last step. I use a textbox for user input of a selected slope, and a TextChanged event to perform the final calculation. But the moment I enter one character, my event handler is called. I thought it would wait until I tabbed away from the field, or until I pressed Enter to process the change, but apparently not. If I enter, for example, 1.234, it works fine (except that the answer is an overflow in this equation), but if I enter a decimal point, as in .016, the instant I enter the point I generate an exception - invalid format.
What am I doing wrong here? Is there another event I should use? Can I fix this one?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: Is there another event I should use?
You might want to try the Validating event.
Roger Wright wrote: Can I fix this one?
I've done this in the KeyDown event in the past, FWIW.
if (e.KeyCode == Keys.Enter)
{
double x;
if (!double.TryParse(txtBox.Text, out x))
{
MessageBox.Show(txtBox.Text + " is not a valid number");
}
}
I wouldn't do any real validating in the TextChanged event, since you can correctly type partial numbers that won't validate until you type the whole thing.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
the normal thing to do, most of the time, is to have one or more input controls that gather input parameters, but don't launch anything major; and a launch control, say a Button. So the user basically says very explicitly "I'm done, now you compute".
you can try without in simple cases, when (almost) all conceivable input values can be handled; this seldom includes the input of floating-point numbers, as you discovered.
one alternative is to use a time-out, i.e. a timer which gets reset and launched on every key stroke/mouse click into the input controls; when the timer fires, no parameter change has been applied for the last N milliseconds, so the input phase is assumed to be finished, and the compute phase is started automatically.
and then you could rely on a special key, say the ENTER key. That takes a little KeyDown handler, as you well know by now. It may be tricky to get comfortable with that solution when more than one TextBox is involved though.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I was hoping to make an interactive form, with changes to the pipe slope triggering new results without requiring an explicit button click to recalculate, but that may be beyond my present capability. The dimensions are generally static values, dictated by the design, so they don't change much. This is all new to me, being an electrical engineer pressed into service as a civil engineer, so I'm still learning a lot. I did a sensitivity analysis on the basic equation for flow and found that slope is about 10000 times more important than dimensions, so I chose slope as my primary variable for tweaking the design. I think my best solution for now is to eliminate the textbox event handler and add an Evaluate button. Later, when I get smarter about building Windows solutions, I can go back to trying to make my original design work.
Thanks for your invaluable help, Luc.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
You're welcome, Roger.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
The TextBox.Leave event is fired whenever tabbing out.
TextBox.KeyDown to check for Enter event.
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
MessageBox.Show("You pressed enter! Good job!");
}
}
|
|
|
|