|
Create a function in your class e.g. ShowErrorMsg
pass Active form as parameter and use this syntex
MessageBox.Show(ActiveForm, "Error: " & vbNewLine & vbNewLine & msg, My.Application.Info.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
|
|
|
No, that is useless
1 - Application.Current.MainWindow works anywhere
2 - his issue is that he's in a dll, or he's just not scoped Windows.Forms.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: 1 - Application.Current.MainWindow works anywhere
Not in applications without UI's...
The simple answer is that DLL's should never try to make messageboxes unless they are part of the UI. Classes that create errors like that should bubble the error up to a UI or logging component using mechanisms like "throw". That way the application can decide how to alert the user, whether through UI pop-ups, log files, etc.
I've also found it very useful to create an application settings file and store error text information in there, rather than hard code error strings in the application. This allows me to ensure that the grammar, punctuation, spelling, and format of errors are all the same throughout the application. It also makes it very easy to edit particular errors if your test team says that the text is incorrect or vague, you just look in the setting file instead of combing through thousands of lines of code to find every instance.
|
|
|
|
|
If this does not work, then you must import the Windows.Forms dll into your dll, or you need using Windows.Forms at the top of your class. Intellisense will show you the namespace you need if you hover the mouse over the end of the statement that has the error. You're really better off throwing an exception tho and letting your presentation layer decide how to deal with it. You can use Application.Current.MainWindow to specific a parent to the messagebox anywhere inside your windows forms app.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello friends,
I have a program to connect to url using HttpWebRequest object and download a file from that url.
I have set
httpwebRequest.Proxy = null;
Question: In my application, no setting field available for to define the specific proxy settings - so, does the my programming foresee to use by default the internet explorer proxy setting?
or are there any other ways to bypass the proxy?
Thank You
|
|
|
|
|
Hi...
I had a group of computers in LAN. In one of the Systems one PC is server which is having MYSQL databse. I want to connect from another PC which is in LAN. My LAN server name is "Desktop1".
I am using the Connection String as
Constr="Server=Desktop1;User Id=root;Password=sa;";
in c#.net. But it is not connecting the Server which is having MYSQL database. To establish the connection in between the PC's am i need to do anything more.....
Plz help me . I am looking for this from a loooong days...
Thank you...
|
|
|
|
|
I believe you need \\Desktop1, to create a network path.
gopal_bnvs wrote: Plz help me . I am looking for this from a loooong days...
Well, that's a little concerning. If you can't work out a connection string, I'd be worried about your ability to do C# AND SQL.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Heelllllll
I tried evrythng....
but its not connecting...
If u knows y don't u mention the connection string.....
|
|
|
|
|
Like I said, it's plain that programming is probably beyond you.
You can have a connection string to a local file, so you need to start your connection string with \\ to show it's a network path. Like I said.
If you can see the machine over the network, then your issue is the connection string, perhaps the user the program runs under, or a combination of the two.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
You need to specify the database name as well. Check out ConnectionStrings.com to see all kinds of connection strings.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hellooo
i searched all and tried all ...
if u knows abt that y don't u mention the connection string?????
|
|
|
|
|
I think we're being flooded by trolls at the moment. I'd put money on this guy being CSS or someone else pretending to be a moron and laughing their head off.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Any plans to reopen the blog now?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
how to run the style marquee? becoz i cant run watever i do.please help me
|
|
|
|
|
How to place an image in the range (cells[5,1],cell[10,5]) of excel? and how to make it in the center of the range?
thanks!
|
|
|
|
|
I hate Excel!
Don't you place the image in the value of Cell(5,1)
I would select the range
Set the vertical and horizontal alignment
Merge the cells
Then add the image
The above is a guess but it seems reasonable.
|
|
|
|
|
This is a wrong place to ask this question
|
|
|
|
|
I need to use an incremental counter, by means of retrieving and updating a value stored in a text file
I know how to use the StreamWriter and the StreamReader classes but what I need to do is to read an int value from a text file, then increment the value by one and write it back to the file.
Is there a way to place a lock in the file while doing both operations? The reason for that is to avoid multiple concurency.
Also, how can the file be checked if it is locked?
Thanks,
CBenac
|
|
|
|
|
If all interested parties are instances of the same app which you develop, then you could base the protection on the FileShare parameter in File.Open(); this might fail if remote access and/or foreign file systems are involved. A few simple tests could be in order.
If all interested parties are threads in a single app, then you wouldn't need a file, just use Interlocked.Increment() on some variable. If need be, save/restore the value to/from a file on app exit/start.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc Pattyn,
The Interlocked.Increment() method is exactly what I need for the application.
Thanks so much for your sugestion!
CBenac
|
|
|
|
|
You're welcome.
May I suggest next time you explain your problem at a higher, more functional level. Apparently the file was a detour, and my gamble for interthread synchronization happened to hit the spot.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
|
Hello,
I have an odd problem. I have a couple of UserControls in my project, and a bunch of instances of them on my Form (with TabPages and other containers to avoid too much clutter). For the most part everything has been fine, but today I tried to modify the definition of one of the UserControls , and whenever I make that control visible on the form (i.e. switch to the TabPage containing it), I can only select controls on my Form from the drop-down list in the Properties page. If I try to click on the control in the designer, the Properties page does not update to show the selection. If I make any changes in the Properties page, those changes affect the last control that was properly selected. If I switch to a different TabPage or hide the control, then everything works fine again.
All I have done to the UserControl definition is remove some properties that I don't need anymore and add a couple of new ones. All the references in my project have been updated and it compiles just fine.
Any ideas? An hour or so of Googling has failed me today (unless my keywords aren't quite right). I've already tried restarting Visual Studio, restarting my computer, reverting to previous versions of the project (previous versions work until I start messing with the control definition), and someone had suggested deleting the contents of C:\Documents and Settings\User\Application Data\Microsoft\Visual Studio\versionNumber.
I am using VS2005 on XP Pro SP2.
Thanks,
Dybs.
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Im not sure if this is bad programming or anything of the kind. But I need to be able to save a property of an object without know what the name of the property will be before hand.
I have an object: objUser, object user might have properties name, surname and age.
So I want to be able to say:
objUser.["Name"] = "Philip";
or
string sProperty = "Name";
objUser.[sProperty] = "Philip;
How do I invoke such a string as a property? (if explained correctly)...
Any help would be appreciated.
|
|
|
|
|
google for .NET reflection, and be warned it will be more complex than what you are hoping for.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|