listbox ?

slowmoe

New member
Joined
May 15, 2005
Messages
3
Programming Experience
Beginner
is there a way to make my app to when you click text in a listbox it will place that text into a textbox in another application and if so how would I go about doing it
 
Use the ListBox.SelectedIndexChanged event handler like so:
VB.NET:
[color=Blue]Private Sub[/color] ListBox1_SelectedIndexChanged([color=Blue]ByVal[/color] sender [color=Blue]As[/color] System.Object, [color=Blue]ByVal[/color] e [color=Blue]As[/color] System.EventArgs) [color=Blue]Handles[/color] ListBox1.SelectedIndexChanged
  [color=Blue]Me[/color].TextBox1.Text = [color=Blue]Me[/color].ListBox1.SelectedItem
[color=Blue]End Sub[/color]
This code assumes that the items in your ListBox are Strings. If your ListBox is bound to a data source you will need to use the appropriate property or field of the selected item.
 
that would work wonderful if the textbox was on the same application but how can i get the listbox string text into another text field that is not on the app that the listbox is on?
thanks
 
My apologies. I didn't notice that very important point. I think you'll still use the same event handler but you'll have to employ some form of interprocess communication. My first suggestion would be to use sockets but I'm not well experienced with IPC so someone else will, no doubt, have more information or a better idea.
 
Hi,
Whilst the .NET Framework has some very sophisticated techniques for communication between processes on different machines, it doesn't provide so much support for communication between processes on the same machine. But anyway Windows API offers a rich set of inter-process communications features, at various levels of sophistication.

So, you can achieve this by using one of the simplest techniques, the WM_COPYDATA message. The WM_COPYDATA message in the Windows API is specifically designed to make it easier to send a block of data between two applications in different processes.
Anyway, i can advice you to try google for it and find some turorials (about using of WM_COPYDATA) but if you don't findanything useful there please feel free to ask additionally and i'll try to help you out ...

Cheers ;)
 
thanks for the reply I did a search on this and found lots of stuff but am still very unclear on how this works, I tryed a few samples but came up empty. All the samples I looked at were very unclear on how to set the target process, though my idea is not to have a set target just to paste the text clicked in the listbox into any application runing on the desktop with a text field, for testing I have been just using notepad, I also looked at "GetProcessesByName" but still failed to get it to work right any help would be great.

thanks a bunch
 
Back
Top