Results 1 to 5 of 5

Thread: how to make control freeze like design time?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    445

    how to make control freeze like design time?

    1. Can we make the Combo Box not drop down if we click on it even though it have item in the list,
    2. button not click-able even though it have the on_click event..
    3. 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...
    Attached Images Attached Images  

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    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 ¿
    VB.NET MVP 2008 - Present

  3. #3
    New Member
    Join Date
    Dec 2009
    Posts
    5

    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 .

  4. #4
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    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
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: how to make control freeze like design time?

    Try this:

    vb.net Code:
    1. Public Class Form3
    2.     Structure DragInfo
    3.         Dim ControlType As Type
    4.         Dim ControlOffset As Point
    5.     End Structure
    6.  
    7.     Private MyDragInfo As DragInfo
    8.  
    9.     Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10.         Me.AllowDrop = True
    11.         ListBox1.Cursor = Cursors.SizeAll   '' show the size cursor
    12.     End Sub
    13.  
    14.     Private Sub Form3_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragOver
    15.         Dim ctl As Control = CType(e.Data.GetData(MyDragInfo.ControlType), Control)
    16.         ctl.Location = PointToClient(New Point(e.X, e.Y) - MyDragInfo.ControlOffset)
    17.     End Sub
    18.  
    19.     Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
    20.         BeginDrag(CType(sender, Control), e.Location)
    21.     End Sub
    22.  
    23.     Private Sub BeginDrag(ByVal control As Control, ByVal initialLocation As Point)
    24.         MyDragInfo.ControlType = control.GetType
    25.         MyDragInfo.ControlOffset = initialLocation
    26.         control.BringToFront()
    27.         control.DoDragDrop(control, DragDropEffects.Move)
    28.     End Sub
    29. 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

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width