|
quiteSmart wrote: I tried using the double click event of the list box to make some action based on the item that is double clicked in the listBox.
But i discovered that also if i double click on the empty part of the listBox,(not on an item) the event is still fired.
You can programmatically distinguish between the two cases.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote:
You can programmatically distinguish between the two cases.
How to do that?
|
|
|
|
|
use the ListBox.SelectedIndex Property
as stated in MSDN:
Property Value
A zero-based index of the currently selected item. A value of negative one (-1) is returned if no item is selected.
hence, if you got a -1 then no item is selected.
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: Property Value
A zero-based index of the currently selected item. A value of negative one (-1) is returned if no item is selected.
I have already tried this.
It workd fine with one exception when u select an item and then double click in the empty space it gives u the returned index as the index of the selected item
so in short this wont work perfectly.
do u have another suggestion?
|
|
|
|
|
DoubleClick event occurs when the control is double-clicked.
This is a normal behaviour.
Regards,
Bhupi Bhai.
|
|
|
|
|
quiteSmart wrote: do u have another suggestion?
Of course...
You can retrieve the Rectangle of the selected item (if there is one) and then check if it contains the point where DoubleClick occurred.
It follows an ugly example, using VB.NET (was handy, 'cause I had a VB project easyly available... Conversion to C# is straightforward):
Sub ListBox1DoubleClick(sender As Object, e As System.EventArgs)
Dim index As Integer
index = listBox1.SelectedIndex
Dim ev As System.Windows.Forms.MouseEventArgs
ev = e
If index <> -1 Then
Dim rc As Rectangle
rc =listBox1.GetItemRectangle(index)
If rc.Contains(ev.X, ev.Y) Then
MsgBox("Hello")
End If
End If
End Sub
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
in your click handler, try using ListBox.IndexFromPoint()
and test for ==ListBox.NoMatches (which equals -1 I guess)
Luc Pattyn
|
|
|
|
|
Hi there,
In my project (C# Win) .NET 2.0 VS 2005, I am getting an error "Exception has been thrown by the target of an invocation". Can you please give me a clue how to debug this problem ?
Thanks
Emran
|
|
|
|
|
|
Be sure to (recursively) check the InnerException [^] property of the throwed exception.
|
|
|
|
|
hi everybody,
does anybody know how to read from excel sheet through C# coding.
If so please tell me how?
thanks in advance
|
|
|
|
|
|
Thnaks for your response,
but can u give me some code example that uses the OleDB/Jet provider.
thanks,
|
|
|
|
|
how to populate ComboBox using c# as in lookin combobox of open dialog box in windows OS?
i tried, but invain.
thanks in advance
tirumal
|
|
|
|
|
|
Hi there,
I wanna use dockpanel class, MSDN2 example shows to use 'using system.windows' and 'system.windows.controls. The need is when i add these to using directives, there is no such thing exists in C# 2005. Can u please tell me, how can i add these two things or where from i can get these.And also if possible some examples using dockpanel.
|
|
|
|
|
You need .NET Framework 3.0 (I assume you have 2.0)
SkyWalker
|
|
|
|
|
Thanks a lot. I will get back to you, if i need further clarifications.
|
|
|
|
|
How can I install, .net framework 3.0? I installed it from MSDN specified location. But still i am not getting it in VS2005?
|
|
|
|
|
The DockPanel is part of WPF ( Windows Presentation Foundation ) which is part of .Net 3. To install .Net 3 goto http://www.netfx3.com/.
Once you have installed .Net 3 you can get to the DockPanel by referencing "PresentationFramework.dll" then your using statements will work.
|
|
|
|
|
If you say you did, then probably you have to add a reference to PresentationFramework (presentationframework.dll).
SkyWalker
|
|
|
|
|
|
Hi,
how can i detect that my application is running somewhere in LAN?
Want make access to let say 5 running instances in LAN, not more.
Any idea?
Greetings
|
|
|
|
|
Have a central repository where the application logs in/out when starting/terminating.
E.g. by having a central database or using a web service.
|
|
|
|
|
Thar sounds dangerous: what if a logout gets missed (e.g. client app crashed).
After some of these, the server will report the maximum allowed number of users
has been reached though no one is actually using the app ?? SO there is need for
a way to get out of there, and once that solution is known, the whole thing becomes
pointless.
I prefer a broadcast + timeout solution where a starting app tries to get a response
from it's sibblings on all other machines; only the machines running the app would
repond and it there are too many of those, the most recent client would refuse to continue.
AFAIR FileMaker has used such a scheme, and it did not need anything special set up
on any Firewall or so (I guess they used TCP/IP with one of the ports that are open
by default...).
I havent seen any source code on this though...
Luc Pattyn
|
|
|
|