|
use form_click event to do this.. if u r using windows...
|
|
|
|
|
Hi qS,
I tried this out for ya, and could easily reproduce the problem you described. Buttons seem ok (they take care of invoking the Leave event on the ListBox), and handling the MouseDown event on the form takes care of hiding it in that instance. Panels cause a problem as they themselves capture the MouseDown event and therefore its not raised on the Form.
As an aside; I was sure there was a way to override this behaviour to tell specific controls to "pass all mouse and key events up the control heirachy. Each level should then be able to do the same thing - handle or pass the event. I cannot find this although im 90% sure it exists.
There is, like always, a sufficient workaround which is to intercept a control being added to the form and handle its MouseDown event also. You can re-use the same event handler as you used for your Form as they have the same signature (and you want the same behaviour - hide the listbox).
I added 1 button and 1 listbox to a form. I thn added the following event handlers:
private void button1_Click(object sender, System.EventArgs e)
{
this.listBox1.Visible = true;
}
private void listBox1_Leave(object sender, System.EventArgs e)
{
this.listBox1.Visible = false;
}
private void Control_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(sender != this.listBox1)
this.listBox1.Visible=false;
}
The last method there has a check that the mouse down event isnt actually on the listbox were using, as you need the mouse down event to set your selection. Then just override OnControlAdded:
protected override void OnControlAdded(ControlEventArgs e)
{
e.Control.MouseDown += new MouseEventHandler(Control_MouseDown);
base.OnControlAdded (e);
}
Nice!
|
|
|
|
|
Thank you for taking all the time to test my problem and figure out a solution.
Actually i did before the same solution you provided. it is working now.
thanks.
|
|
|
|
|
Hi,
Hope every one is doing fine... well I've a little problem at hand regarding the above stated function... when this function is run in the environment of winXp or lower it works fine... but on Vista it gives different results and hence the comparisons fail very often... is there any other function that could convert BYTES in to STRING in the same way on every Windows Platform i.e. compatible for Vista as well...
Thanks in advance,
Regards.
|
|
|
|
|
Can someone please tell me what is wrong with this code in C#
have 2 web pages: page A and PageB
in page_load event for pageA I want the page to assign a value into a session variable and redirects to pageB, like this:
PageA
Session["Refid"]=1;
Respone.Redirect("pageb?refid="+ Session["Refid"]);
.
When I step run my codebehind by pressing F10, I notice it goes to the catch Exception part of my try...catch event and still redirects to pageB which shoudn't be. I believe once an error is raised it should print the error message instead of redirecting to pageB.
can someone help me out.
Thanks
|
|
|
|
|
What is the exception ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
it doesn't print out any exception instead. I just taught something is wrong bcos when I comment that part and step run my codes it runs (without going to the next page) and does not go the catch exception segement.
when you remove the comment and step run the program again, when it gets to the response.redirect, it jumps straight to the catch exception segment after which it redirects to pageB.
if you can give me an example that works I don't mind.
thanks for taking out time to look at my issues.
expect to get more clues from you.
thanks.
|
|
|
|
|
Thread abort like...........
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Plz use this........
Response.Redirect(url, False)
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
hi acodman,
I think that response.redirect work even for most exceptions.
try putting the aspx page extention and convert the session to string
Respone.Redirect("pageb.aspx?refid="+ Session["Refid"].ToString() );
i think this should work
|
|
|
|
|
always cast ur data before u use it..
Ajay has send the right thing..
Respone.Redirect("pageb.aspx?refid="+ Session["Refid"].ToString() );
|
|
|
|
|
|
|
I have to encrypt and decrypt the date and one value.
How can i do so that it will saved in the database in non regular format.
and also I want to create public and private key so that at the time of installation of software only private key which i have can be used.
unless I don't provide key software cannot installed.
Please help me out.
|
|
|
|
|
The System.Security.Cryptography namespace should be a good starting point. There, you'll find implementations of common symmetric encryption algorithms as well as the RSA asymmetric algorithm.
|
|
|
|
|
i want to convert interger value to character
that interger value contain ascii value.
e.g 65 to A
Hallo
|
|
|
|
|
Char c= Convert.ToChar(65) ;
Char c=(char)65;
both are same
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
I generally works but bear in mind that the char type in .net is not the char type in c.
it has many differences.
|
|
|
|
|
I Need the ConvertAll functionality of list but I need to bind the list to a control and so need it to be a BindingList<>.
How can I add the ConvertAll functionality to a BindingList or is there another type of list I can use?
TIA
|
|
|
|
|
Hi
I am programmatically creating SSIS package. I know to create db to db and db to flat file. I dont know how to create SSIS pacakge programmatically from Flat file to Destination DB. Could any one help me to solve my problem please.
kesavan
kesavan
|
|
|
|
|
I have written a Windows Service that runs without any problems on my test pc and on my development pc, but when I install on the pc's that it is developed for a thread in the service is never started. This thread is very simpel and runs perfectly on test and development pc's. Furthermore the service keeps running and all other threads and parts of the code keep working except for this one thread.
The code has been tested with Unit Tests, I have even tryed to run and debug the service as a program. When run as a program on all pc's (that includes the pc that it is developed for), there are no problems. And there are no exceptions that aren't handled.
My own conclusion was that there might be something wrong with Windows, except that it is the same version of Windows that my test and development pc's are running, and I have tryed to reinstall with no succes.
Is there anyone who can tell me what could be wrong?
KISS
|
|
|
|
|
Hello gurus,
I'd like to know how to convert an array of shorts (or what ever) to an array of bytes to send on a socket?
And vice versa...
Can anybody show me a code snipet please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Take a look at the MSDN topic of the Array.ConvertAll method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Sounds like Buffer.BlockCopy() is what you need. Each short value will be split in half to become 2 byte values in the byte array.
byte[] buffer=new byte[values.Length*2];
Buffer.BlockCopy(values,0,buffer,0,buffer.Length);
|
|
|
|
|
Hi, all!
I have a following problem, and i can't find a right solution.
Description:
There is a COM server written on C++ and it works through IDispatch and it does't have a TYPELIB. And from another side there is a COM client developed on C#. Through LATE BINDING it uses a COM server
and COM server sends different events to client, but i can't implement COM event handling mechanism.
Please, anybody can help me?!
Thanks in advance!
|
|
|
|