REPOST: Selecting region on a form

  • Thread starter Thread starter Dino M. Buljubasic
  • Start date Start date
D

Dino M. Buljubasic

I have a form and a panel on the form that holds 24 user controls each one
representing an hour (0 - 23). The panel is completelly covered with the
user controls.

I need to be able to select user controls and highlight them or select them
(like rubber band) by mouse-down-drag-mouse-up events.

I am trying to capture coordinates of mouse down event on the panel holding
the user controls. However, since panel is under the controls, I can not do
that.

Any suggestions how to do this?

Regards, Dino
 
Dino,

I'm not sure about this but I think the first user control that someone
clicks on and holds the button down will receive all the mouse move events.
So you'll have to use the mouse events of that control. Or you can use
usercontrol.Capture= True to capture all the mouse events.
 
Hi Dino,

Did I not send this example once to you?

It is a month, but does what you say.

Cor

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim start As Integer = 4
Dim top As Integer = 25
Dim i As Integer
Dim mybutton(31) As Button
Dim nowdate As DateTime = DateTime.Now
For i = 0 To System.DateTime.DaysInMonth(2003, nowdate.Month) - 1
mybutton(i) = New Button
mybutton(i).TextAlign = ContentAlignment.MiddleCenter
mybutton(i).Width = 40
mybutton(i).Height = 20
mybutton(i).FlatStyle = FlatStyle.Flat
mybutton(i).BackColor = Drawing.Color.AntiqueWhite
mybutton(i).Location = New System.Drawing.Point(start, top)
mybutton(i).Text = (i + 1).ToString
mybutton(i).Cursor = Cursors.Hand
Me.Controls.Add(mybutton(i))
AddHandler mybutton(i).Click, AddressOf mybutton_Click
AddHandler mybutton(i).MouseHover, AddressOf mybutton_Hoover
AddHandler mybutton(i).MouseLeave, AddressOf mybutton_Leave
start = start + 40
If (i + 1) Mod 5 = 0 Then
top = top + 20
start = 4
End If
Next
End Sub
Private Sub mybutton_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thisbutton As Button = DirectCast(sender, Button)
MessageBox.Show("The day is: " & thisbutton.Text)
End Sub
Private Sub mybutton_Hoover _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thisbutton As Button = DirectCast(sender, Button)
thisbutton.BackColor = Drawing.Color.AliceBlue
End Sub
Private Sub mybutton_Leave _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thisbutton As Button = DirectCast(sender, Button)
thisbutton.BackColor = Drawing.Color.AntiqueWhite
End Sub
///
 
Yes, but what about other controls ?
It seams to be quite simple but the problem is that I can not click on the
form and then rubberband-select the controls. I have to click on my user
controls which represents an hour, and then drag over other user controls
(hours) to select them.

Thanks, Dino

--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


Brian said:
Dino,

I'm not sure about this but I think the first user control that someone
clicks on and holds the button down will receive all the mouse move events.
So you'll have to use the mouse events of that control. Or you can use
usercontrol.Capture= True to capture all the mouse events.


Dino M. Buljubasic said:
I have a form and a panel on the form that holds 24 user controls each one
representing an hour (0 - 23). The panel is completelly covered with the
user controls.

I need to be able to select user controls and highlight them or select them
(like rubber band) by mouse-down-drag-mouse-up events.

I am trying to capture coordinates of mouse down event on the panel holding
the user controls. However, since panel is under the controls, I can
not
 
Back
Top