|
hi
in my code, i am saying
button.enabled = false;
...
...
...
...
progressbar.performstep();
label.text = "Pass";
button.enabled = true;
the button is grayed out during this, but if i have clicked during this, it takes the click event after "Pass" is displayed.
how do i prevent this? i need an urgent solution. please see if anyone can help me with some suggestion.
thanks.
|
|
|
|
|
What you exactly want button click will be fired after the text chenges to pass because you have enabled the button.
|
|
|
|
|
i am clicking the button before the text changes to pass.
|
|
|
|
|
Hi
In a separate thread, check the messages in application queues parallely.
If any message of button click comes and you are doing "pass" processing work
delete that message from application quese. Size of application queue would be 8.
|
|
|
|
|
Can anyone tell me how I can have a control tht I don't want other classes to inherit?
I have a base class and the child class needs to inherit but I don't want it to inherit one of the comboboxes. I need to delete it.
I tried to go into the designer class and declare protected but it still inherits.
Thank you
Sianny aka Sharny
|
|
|
|
|
Hi,
Make it as a sealed class.
|
|
|
|
|
i suppose use non abstract class but not sure
|
|
|
|
|
No. A non abstract class is just a class that can be instantiated. The answer to this is to make the class sealed so that it cannot be inherited from.
public sealed class CannotBeInherited
{
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How to copy a file to a different folder?
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
fi.CopyTo(Destino + "\\" + fi.Name);
}
or
File.Copy(source,destination);
|
|
|
|
|
Please put your code in <pre> tags so it is readable.
What is fis and files ? From the little bit of context provided, can we assume fis is defined as FileInfo[] ? There are multiple possibilities for files , most of which imply that it is some sort of collection or array. In that case, you won't have a CopyTo method.
There is also not a CopyTo(String, String) method on FileInfo , so is it safe to assume that you actually meant File.Copy(String, String) ?
In either case, both methods only operate on an individual file and all parameters must be a fully qualified file name.
They do the same work and one really isn't any faster than the other, so it all depends on how you are getting the original file.
|
|
|
|
|
I have a form with 3 textbox. when you press Tab then the textbox have a character which was blacken to you put new character. how i do it? Can you help me!
|
|
|
|
|
cam chuong wrote: when you press Tab then the textbox have a character which was blacken to you put new character.
Uhhh, what?? I have no idea what you're talking about. Are you saying that you WANT IT to put a small black box in the textbox when you hit the "Tab" key??
cam chuong wrote: how i do it? Can you help me!
Not unless you describe the problem better.
|
|
|
|
|
can i design my control style and shape as i like
for example like "jetAudio" program bottons
|
|
|
|
|
iprotoo wrote: can i design my control style and shape as i like
Sure. Permission granted. With a question like this, there's really no other answer possible. You just asked if you could do it. Sure, why not? The real question comes in now, "Do you have the ability to do it??" Only you can answer that...
Or did you have a real question, like what part of creating your own custom button class are you stuck on??
iprotoo wrote: for example like "jetAudio" program bottons
Never heard of it.
|
|
|
|
|
You can, and this is done using owner drawn code, so that's what you want to google on.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I'm not sure if what I'm after is possible.
I have 3 values stored in the DB, two being variables and the third an operator (ie =, !=, >= etc) - all stored as a string.
What I need is a function that evaluates the 2 variables based on the operator and returns true or false.
so if(var1 operator var2)
return true;
else: return false;
I know that I could do a switch statement to check what the operator is and then type the code for it, but I was wondering if there is a dynamic way in which I could get at the operator based on the string values of "=" or ">=" etc ? That would enable me to add more operators to the db without changing code. The operators I need to support from the start are =, !=, >, <, >=, <= however there might be more in the future.
Any help greately appreciated.
Jo
Joasia
|
|
|
|
|
You could use the CSharp.Compiler (see this article http://www.codeproject.com/cs/algorithms/matheval.asp[^]), but if you're concerned about efficiency at all, I'd go with the switch statement.
If you're using 2.0, you could write a template generic comparer class to handle variables of any type.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
There might be a fancier/more efficient way, but this works:
public class OpEval<T> where T : IComparable<T>
{
public static bool Eval( T arg1, T arg2, string op )
{
int c = arg1.CompareTo( arg2 );
switch( op )
{
case "=":
return c == 0;
case "!=":
return c != 0;
case ">":
return c > 0;
case "<":
return c < 0;
case ">=":
return c == 0 || c > 0;
case "<=":
return c == 0 || c < 0;
default:
throw new ArgumentException("Invalid operator");
}
}
}
Call like:
bool equal = OpEval<int>.Eval(50, 60, "=");
You get the idea...
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Or make a method for each operator, and have a Dictionary of them?
Hmmm... it's Friday...
|
|
|
|
|
Thanks for the opportunity to write this, may not be exactly what you want, but it was fun:
namespace Template
{
public partial class Template
{
public delegate bool opdelegate<T> ( T x , T y ) where T : System.IComparable ;
private static readonly System.Collections.Generic.Dictionary<string,opdelegate<System.IComparable>> ops ;
static Template
(
)
{
ops = new System.Collections.Generic.Dictionary<string,opdelegate<System.IComparable>>() ;
ops.Add
(
"=="
,
delegate
(
System.IComparable x
,
System.IComparable y
)
{
return ( x.CompareTo ( y ) == 0 ) ;
}
) ;
ops.Add
(
"!="
,
delegate
(
System.IComparable x
,
System.IComparable y
)
{
return ( x.CompareTo ( y ) != 0 ) ;
}
) ;
return ;
}
[System.STAThreadAttribute]
public static int
Main
(
string[] args
)
{
int result = 0 ;
try
{
if ( ops [ "==" ] ( args.Length , 3 ) )
{
System.Console.Write ( ops [ args [ 1 ] ] ( decimal.Parse ( args [ 0 ] ) , decimal.Parse ( args [ 2 ] ) ) ) ;
}
else
{
System.Console.Write ( "Syntax: Compar num op num" ) ;
}
}
catch ( System.Exception err )
{
System.Console.Write ( err.Message ) ;
}
return ( result ) ;
}
}
}
|
|
|
|
|
Hi everyone,
i have a datagridview for adding/updating rows to the sqlserver database..before adding a new row to the database, i want to check whether the record already exist in my databse to avoid dubble records in the database...any idea how to do that?
thanx,
djavid
|
|
|
|
|
Write a method in your C# code that calls a stored procedure that checks, based on the data being added, whether a matching record already exists.
Paul
|
|
|
|
|
Also you can set the column of the data grid's datatable which need to be unique to be true.
|
|
|
|
|
Hello everyone,
I was wondering if there is a way I can add some information like a serial number to a file. I am currently doing this with adding the serial number to the file name using the System.IO.FileInfo class.
Would it be possible to have the serial number somewhere more safer. something like Metadata used in mp3 file.
Thank you very much and have a great day.
Khoramdin
Khoramdin
|
|
|
|
|
Hi
Encrypt your serial number and keep it in registry/file.
Vikas Maan
|
|
|
|