|
Umm... what's the question?
|
|
|
|
|
sorry. figured it out myself alreay.
thanks
|
|
|
|
|
please don't delete messages, just add a reply or edit the subject line.
deleting or clearing messages results in a messy forum.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
the question should have been: can I do the same without any if, and half the amount of code.
the answer is yes, you can.
and BTW the last statement should have been inside the else block.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Noted your point. Thanks
It works great
|
|
|
|
|
Forgot to mention, when a button's function changes, it is polite to reflect that in its Text.
Helps preventing user confusion.
[ADDED]Still doesn't need an if, the ?: operator is great for such things.[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
please i need an advice on how i can learn this language very fast. i have some knowledge of c programming and c++. can i learn more myself just by reading. thanks
|
|
|
|
|
Hi,
yes, you can learn the basics of any language from a tutorial book. Go to the bookstore, look at a couple of C# books and buy the one or two that you like most. Work your way through the initial chapters and try a few things on a PC to make it sink in. Skip specialized chapters you don't yet need (databases, networking, ...).
Then read some of the excellent articles here on CP.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Best piece of advice I've seen in a while. 5'ed.
|
|
|
|
|
You have been given an excelent piece of advice from Luc; a man very well respected on this forum. All I can add is that you should take it!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I can't agree with the one-voter that hit you
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
FWIW: I have seen that sig before, WNW
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: I have seen that sig before, WNW
Can't be mehim! He was a Brit, dontcha know, and Hungarian I am.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I agree with Luc, but I would add - C# has a LOT of gotchas for someone who assumes that it's like C++, it just LOOKS like C++. If you hope to read a couple of articles and then start a C# project, I would say you need to tread with care.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
There are some specific differences between C++ and C# that you should be aware of, like for example how the memory management differs. I made a search on MSDN for some article about the differences between C++ and C#, and realised that a lot of the articles in the search result would be relevant.
MSDN: search for C# C++[^]
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
While I do not know for sure IIRC a sheet may be created and deleted and still reside in the metadata in excel. Also I think renaming a sheet sometimes left a copy of the original name in the metadata. One of the reasons we avoid Office apps whenever possible.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I have just recently been jumped into C# and its all been a nice learning process. Many times I've had thought to ask here some questions but while typing in the question I have come to some ideas or questions that with google I could solve myself, coming into working solution. So now I am asking is this a good practice...
What problem I had:
Multiform MDI desktop application which had a expiring login system based on time from last user activity. Login dialog would be popped only when certain functionality is launched by user activity. When login has expired the application would just disable certain functionality. Reason for this behavior is to have the application work as a "viewer" all the time and require login only when certain "writing operation" would occur.
Generalizing the problem I thought I need object to maintain whole application (class where the entry point is) which would handle all this using class that's designed to handle all login-related functionality.
So, I wrote a "Login" class which is defined in "Program" class. I also wrote new class that inherits System.Windows.Forms.Form and all my forms inherit from this class. This "customForm" class I have all the basic login functionality:
public partial class customForm : Form
{
public event EventHandler<EventArgs> RefreshActivityEvent;
public void LoginInvalidated(object sender, EventArgs e)
{
}
protected virtual void OnRefreshActivity(object source, EventArgs e)
{
EventHandler<EventArgs> handler = RefreshActivityEvent;
if (handler != null)
{
handler(this, e);
}
}
}
public class Login
{
private System.Timers.Timer InvalidationTimer;
public event EventHandler<EventArgs> TimedEvent;
public string foo;
public Login()
{
InvalidationTimer = new System.Timers.Timer();
InvalidationTimer.Interval = 10000;
InvalidationTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
InvalidationTimer.AutoReset = false;
InvalidationTimer.Start();
}
protected virtual void OnTimedEvent(object source, ElapsedEventArgs e)
{
EventHandler<EventArgs> handler = TimedEvent;
if (handler != null)
{
handler(this, e);
}
}
public virtual void Restart()
{
InvalidationTimer.Stop();
InvalidationTimer.Start();
}
}
"Login" class has event to fire when timer triggers.
"customForm" class has event to fire when user activity occurs (to reset the timer).
In "Program" class constructor I add delegates to each of these events:
FirstForm.RefreshActivityEvent += new System.EventHandler<EventArgs>(RefreshActivity);
SecondForm.RefreshActivityEvent += new System.EventHandler<EventArgs>(RefreshActivity);
LoginObject.TimedEvent += new System.EventHandler<EventArgs>(FirstForm.LoginInvalidated);
LoginObject.TimedEvent += new System.EventHandler<EventArgs>(SecondForm.LoginInvalidated);
So, Program.RefreshActivity() will reset the LoginObject's timer. customForm.LoginInvalidated() is method I can overwrite to add "disabling features" code for each form and then call base class LoginInvalidated() method to maintain basic login functionality.
What I achieve with this is when timer reaches end, each form "knows" the login has expired... and when each form have any user activity, the main program knows this (in RefreshActivity method).
As this is the very first time I do anything like this, I would like experienced opinion if this is the "right way" of doing this?
Next step is to make event for login request in customForm class which would fire Login object in the Program object to pop up the login dialog and forward the information of the login status to the form, also firing LoginValidated in order to enable features that require login. But before I proceed in this, I'd like to have the comfort of knowing I am not doing this the "hard way" just because there's a feature I have not yet stumbled on that would be commonly used for something like this.
Sorry for the long post.
|
|
|
|
|
Looks fine to me, except for class names. I would also move the hooking up of LoginObject and form to a separate class. If there is more than one form, I'd also consider storing them in an array instead of individual variables.
And oh, you're firing the TimedEvent from the System.Timers.Timer thread and have hooked up LoginInvalidated method on System.Windows.Form. Unless you're absolutely sure that you're not going to touch any UI objects, you'll have to use Invoke/BeginInvoke[^]
|
|
|
|
|
So you mean my LoginInvalidated method will be running in different thread than my System.Windows.Form object...
Looks like I dug too deep finding implementation to this and it's time to try something else.
Guess if I keep my MDI parent form as the host and run System.Windows.Forms.Timer to tell me about the expiration, I will be running the timer in same message pump and am safe to touch UI elements in the MDI parent and its MDI childs as theyre shown using .Show method?
And, uh, how would you store multiple forms in an array?
(edit)
OR
I could use static class for running the timer and just read its properties to find out the status of login? It would be less fancy though
modified on Thursday, June 4, 2009 2:37 AM
|
|
|
|
|
Raybarg wrote: So you mean my LoginInvalidated method will be running in different thread than my System.Windows.Form objec
Yes.
Raybarg wrote: Guess if I keep my MDI parent form as the host and run System.Windows.Forms.Timer to tell me about the expiration, I will be running the timer in same message pump and am safe to touch UI elements in the MDI parent and its MDI childs as theyre shown using .Show method?
Yes.
Raybarg wrote: And, uh, how would you store multiple forms in an array?
Form []forms = new Form[2];
forms[0] = FirstForm;
forms[1] = SecondForm;
...
or if the number of forms is not fixed, you could use a List <Form> instead.
Raybarg wrote: I could use static class for running the timer and just read its properties to find out the status of login? It would be less fancy though
I'd rather do it the way you're doing right now - firing a TimerExpired event.
|
|
|
|
|
Hi, i have installed mysql connector so that my application can work with mysql database located at a web server.
i imported this
using MySql.Data.MySqlClient;
when i complied the application, it works fine on my computer. however when i sent my friend the application, he got an error saying
cannot load file or assembly "Mysql.data, version 6.0.3.0 culture=neutrel, publickeytoken=c5687fc88969c44d' or one of it dependencies.
must he install sql connector as well to run my application?
|
|
|
|
|
You need to place the dll for the connector in his GAC or in the application bin directory, or install the connector.
|
|
|
|
|
May i know what is GAC?
meaning i have to send the dll and the exe to him?
possible to combine and just send him 1 file?
|
|
|
|
|
GAC = Global Assembler Cache
And yes, you can create an installer project and deliver him a single MSI that will do all of the work.
|
|
|
|