|
Will generics solve the problem?
|
|
|
|
|
Any time you get some weird code from somewhere the best place to get answers when it doesn't work is to ask in the same place you got the code.
I don't really understand your goal. If your developers can't be relied upon to remember simple things then expecting them to use things like dynamic enums is probably a bad idea. Maybe if you gave an example of how it would be used we could give you an alternative. If the enum isn't built until runtime I don't see how it can give any advantage to someone at coding time.
|
|
|
|
|
Good day one and all,
I've been given a little task to create a petrol station app. The app allows for multiple "pumps" with the option of adding more petrol/gas pumps where required. Currently my app displays only one pump at a time and you change between pumps with a combo box.
Obviously in the real world you can have multiple pumps all running concurrently, so I wanted to duplicate the same form everytime a new pump class was created/instantiated.
Does anyone have a pointer on the simplest way for me to do this? A pointer to some code to look at would be ideal as I'm no coding guru at the moment.
Thanks all,
Mike.
|
|
|
|
|
Have you tried:
MyPumpForm newPump = new MyPumpForm();
newPump.Show();
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Cheers matey, that's getting me somewhere. I didn't think it would be quite that simple...
|
|
|
|
|
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"
|
|
|
|