1 Attachment(s)
how to make control freeze like design time?
- Can we make the Combo Box not drop down if we click on it even though it have item in the list,
- button not click-able even though it have the on_click event..
- textbox not allow to set focus but not in disable mode...
everything like design time.. because I want to do drag and drop control like visual studio.. but I can drag now, just when I want to click the control to drag, the control still remain the default function...
Re: how to make control freeze like design time?
You'll have to create your own contol which inherits from ComboBox, but with all the functionality you've mentioned. Do you know how to make user controls ¿
Re: how to make control freeze like design time?
Your Control should implement the IMessageFilter Interface, and then have to add a message filter to the application to block the appropriate functionalities like mouse clicks .
Re: how to make control freeze like design time?
Try refer this , but the button is not correctly.It is only true when you first click. I have not modified yet. :)
Code:
'combox not dropdown
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.MouseMove, ComboBox1.MouseClick
ComboBox1.DroppedDown = False
End Sub
'Textbox not focus
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus
Button1.Focus()
End Sub
'button not click able
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RemoveHandler DirectCast(sender, Button).Click, AddressOf Button1_Click
MsgBox("manhit")
End Sub
Re: how to make control freeze like design time?
Try this:
vb.net Code:
Public Class Form3
Structure DragInfo
Dim ControlType As Type
Dim ControlOffset As Point
End Structure
Private MyDragInfo As DragInfo
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AllowDrop = True
ListBox1.Cursor = Cursors.SizeAll '' show the size cursor
End Sub
Private Sub Form3_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragOver
Dim ctl As Control = CType(e.Data.GetData(MyDragInfo.ControlType), Control)
ctl.Location = PointToClient(New Point(e.X, e.Y) - MyDragInfo.ControlOffset)
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
BeginDrag(CType(sender, Control), e.Location)
End Sub
Private Sub BeginDrag(ByVal control As Control, ByVal initialLocation As Point)
MyDragInfo.ControlType = control.GetType
MyDragInfo.ControlOffset = initialLocation
control.BringToFront()
control.DoDragDrop(control, DragDropEffects.Move)
End Sub
End Class
What I showed above is just with one list box for sample. You can add as many controls as you want and code it accordingly (control's MouseDown event). You can also make a common MouseDown event handler for all controls.