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...
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 ¿
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 .
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
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.
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering