|
ok, thanks very much, i will try.
|
|
|
|
|
having a map
i want to point locations on that map when clicking on it
so i thought of creating a label and setting the location of that label same as the location of the mouse click event
so far so good,
but the prob is that : i want to point to more then 1 location
so any hint of how can i create as many labels as i clicked on the map?with location of the labels as location of the mouse clicked?
this is what i used till now
Private Sub Form2_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick<br />
<br />
Me.Label1.Location = New System.Drawing.Point(e.Location.X, e.Location.Y)<br />
Me.Label1.Visible = True<br />
end sub
if there is any other hint let me know plz
thx
Regards
Ramy
|
|
|
|
|
You need to dynamically create the label in the function. Somthing along the lines of:
<br />
Dim lbl As New Label<br />
<br />
lbl.Location = New System.Drawing.Point(100, 100)<br />
lbl.Text = "This is a test"<br />
lbl.Visible = True<br />
Me.Controls.Add(lbl)<br />
Mike Lasseter
|
|
|
|
|
thx it worked
i forgot to add : Me.Controls.Add(lbl)
-----
i want to ask another thing ,after adding these labels...how can i click on each lables ?
i mean when i click on label do action ... ex : msgbox("hello")
Regards
Ramy
|
|
|
|
|
<br />
Public Sub AddLabel()<br />
Dim lbl As New Label<br />
<br />
lbl.Location = New System.Drawing.Point(100, 100)<br />
lbl.Text = "This is a test"<br />
lbl.Visible = True<br />
Me.Controls.Add(lbl)<br />
AddHandler lbl.Click, AddressOf Label_Click<br />
End Sub<br />
<br />
Private Sub Label_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) <br />
MessageBox.Show("this is a test")<br />
<br />
'You can remove the handler like so if necessary<br />
Dim lbl As Label = DirectCast(sender, Label)<br />
RemoveHandler lbl.Click, AddressOf Label_Click<br />
End Sub<br />
I noticed that you are using suggesting using msgbox. You really should avoid using this since it is in the Microsoft.VisualBasic namespace which allows the legacy commands to work. You should use the .Net commands when possible.
Mike Lasseter
|
|
|
|
|
so far so good... thx
before i thought about the ideas of adding labels
i thought of doing the following :
FillEllipse(m_brush, 0, 0, m_width, m_height)
and everything went good.
but i couldnt click on each added ellipse any hint for that (like the idea of the labels)
AddHandler lbl.Click, AddressOf Label_Click
is there a way like : AddHandler ellipse.click ??
Regards
Ramy
|
|
|
|
|
Since the ellispe is not a control it will not support events. The only way I can think of with an ellipse is to keep track of the ellipses you have created and the area they cover. Then in your click event you can see if the mouse click was in the area of the ellispe. Then you will perform what ever action you want.
Other than that you could create your own user control. There are plenty of examples for this if you use google.
Mike Lasseter
|
|
|
|
|
lets get back to the idea of creating labels.
lets suppose 1 i created 10labels,how can each lable perform different action ?
Regards
Ramy
|
|
|
|
|
You can store what type of label it is in the tag property. Then in your click event handler you can do cast the sender (the sender will be the label that was clicked) as a label then access its tag property. Based on its tag property you can perform your desired actions.
Mike Lasseter
|
|
|
|
|
kindly,
can u help me with this issue ?
mr_lasseter wrote: You can store what type of label it is in the tag property
because i m new with this Tag thing..Thank you
Regards
Ramy
|
|
|
|
|
Public Sub AddLabel()
Dim lbl As New Label
lbl.Location = New System.Drawing.Point(100, 100)
lbl.Text = "This is a test"
lbl.Visible = True
'isCity & isState are made up values
if isCity then
lbl.Tag = 1
elseif isState then
lbl.Tag = 2
end if
Me.Controls.Add(lbl)
AddHandler lbl.Click, AddressOf Label_Click
End Sub
Private Sub Label_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim lbl as Label = DirectCast(sender, Label)
if lbl.Tag = 1 then
messagebox.show("You clicked a city")
elseif lbl.Tag = 2 then
messagebox.show("You clicked a state")
end if
End Sub
Mike Lasseter
|
|
|
|
|
How would i code a loop to go through a listbox and take each value out of it to insert the values into textboxes?
Would i use a loop?
Dim strLan As String
strLan = lstX.SelectedIndex() = 0
txtX.Text = strLan
This code isnt working for me, somthing pretty damn basic i know!
|
|
|
|
|
Yes, you would use a loop like this:
For Each strLan As String In lstX.Items
txtX.Text += strLan
Next
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Ex: puts all the values into 1 textbox.
For i As Int16 = 0 To ListBox1.Items.Count - 1
TextBox1.Text += ListBox1.Items(i).ToString
Next
not sure how you plan on managing the number of textboxes on the form because depending on the number of items in the listbox, it could get out of hand...
|
|
|
|
|
Thanks for the help!
Thing is, i have up to 8 in the list box, and each element in that listbox is to go to a different textbox.
Sorry, but i just cant figure it out!
Thanks!
|
|
|
|
|
let's step back and see what you really want to do...
1) how does the listbox get fed? (what dictates 'up to 8')
2) are you creating the textboxes on the fly or are all 8 on the form all the time?
|
|
|
|
|
Sorry for the delay!
Basically i have a list box populated with items from another listbox, drag and drop basically.
Within a different groupbox, i have 8 different textboxes.
How do i take the first element from the listbox and put it into the first textbox, second to second etc... They are all on the form at the same time.
Can a loop easily do this?
Thanks
|
|
|
|
|
I see 2 "simple" options...(there are more complex but I dont' have time to show you how to do these)
1) manually check the index of the for next loop assign it to each associated textbox
ex:
for i as int16 = 0 to listbox1.items.count-1
select case i
case 0: textbox1.text = listbox1.items(i).tostring
case 1: textbox2.text = listbox1.items(i).tostring
.
.
end select
next
2) put the index in the tag property of each textbox
ex:
textbox1.tag = "0"
textbox2.tag = "1"
etc.
for i as int16 = 0 to listbox1.items.count-1
for each oCtrl as control in me.controls
if typeof(octrl) is textbox then
with ctype(octrl,textbox)
if .tag = i.tostring then
.text = listbox1.items(i).tostring
exit for
end if
end with
end if
next
next
|
|
|
|
|
thanks, ill give it a go!
|
|
|
|
|
I need to be able to prevent Windows from powering-down while my VB6 application is running.
|
|
|
|
|
You can find an example here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello Gurus
I got an application developed in vb.net, for the deployment of it I need to cutomize that.
I need to provide four option (checkbox) to user during the installation & based on the selection the installer should write the values in registry, I know how to provide the four options(checkbox) as well as how to write values in registry, The only bit I don't is how to check those option provided or choosen by the user(s). Please reply ASAP:
|
|
|
|
|
Hi All,
Can anybody let me know how to schedule an event through coding in Developer Express in Vb.Net
Thanks & Best Regards,
Noor.
Noor
|
|
|
|
|
Schedule an event?? What event? What is this app supposed to be doing? And what's "Developer Express"?? Are you talking about Visual Basic .NET Express Edition?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Sorry, I will clear the question.
I want to fix an appointment on some day (For eg 14-02-2007). I want to display it in Developer Express(Thirt Party Tools) Scheduler like we used to display in Microsoft Outlook Calendar.
Hope This Question is clear to answer.
Thanks & Best Regards,
Noor.
Noor
|
|
|
|