Inivsible Button

Hi,

Could someone tell me how to make a button that isn't seen to the user, but still can be pressed If i use button1.visible = false then you can't press it.

Thanks in advance,

Josh



Answer this question

Inivsible Button

  • svenderuyter

    Set its FlatAppearance.Border to 0 and the BackGround to Transparent, FlatStyle = Flat and no text. So it should be transparent but clickable.

    --
    SvenC


  • WaYdotNET

    Or you could use a Label control with a transparent backcolor. I think ;)

  • ehsan sadeghi

    Also, I get this when i try to change flat aperance/button border to transparent in the properties:

    ButtonBase controls do not support setting the BorderColor to Transparent.


  • sascue

    I thought of that Idea too...But-I have am image in the backround.

    I can post all my codes in a bit, but I g2g now...

    c ya soon!


  • Uncle Ted

    Make a label with blank text as shown below:

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    Partial Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

    If disposing AndAlso components IsNot Nothing Then

    components.Dispose()

    End If

    MyBase.Dispose(disposing)

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

    Me.Label1 = New System.Windows.Forms.Label

    Me.SuspendLayout()

    '

    'Label1

    '

    Me.Label1.AutoSize = True

    Me.Label1.Location = New System.Drawing.Point(0, 0)

    Me.Label1.Name = "Label1"

    Me.Label1.Size = New System.Drawing.Size(52, 13)

    Me.Label1.TabIndex = 0

    Me.Label1.Text = " "

    '

    'Form1

    '

    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

    Me.ClientSize = New System.Drawing.Size(292, 266)

    Me.Controls.Add(Me.Label1)

    Me.Name = "Form1"

    Me.Text = "Form1"

    Me.ResumeLayout(False)

    Me.PerformLayout()

    End Sub

    Friend WithEvents Label1 As System.Windows.Forms.Label

    End Class

    Public Class Form1

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    MsgBox("test")

    End Sub

    End Class



  • Leaf.

    Heres my code:

    Public Class Form1

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    PictureBox1.Visible = True

    Button2.Visible = True

    Button1.Visible = True

    NewUser.Visible = False

    Button3.Visible = False

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    NewUser.Visible = True

    Button3.Visible = True

    PictureBox1.Visible = False

    Button2.Visible = False

    Button1.Visible = False

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    UC.Visible = True

    Button4.Visible = True

    Button5.Visible = True

    PictureBox2.Visible = True

    Button1.Visible = False

    Button2.Visible = False

    PictureBox1.Visible = False

    username.Visible = True

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

    PictureBox1.Visible = True

    Button1.Visible = True

    Button2.Visible = True

    PictureBox2.Visible = False

    Button4.Visible = False

    Button5.Visible = False

    username.Visible = False

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    End Class

  • PK2000

    Talldude, I found a way to do this that will fit my needs, but, now I have a new similar problem.

    1. If i make a label with spaces it shows up as a grey rectangle

    2. To fix the buttons I just took a screenshot, edited out the parts I didn't want in Paint, then used that as a button image.

    3. Now I need a TextBox that you can type in, but transparent. I'll try the image editing thing, but I don't think it will work...

    -Josh


  • Benj78

    If your form had it's default settings, with

    a background color of 'control' and no

    background images or the like added, then

    the label would have appeared as 'invisible.'

    If you keep the default settings, and change the

    textbox backcolor to 'control' and change it's

    border style to 'none', it will also appear 'invisible.'

    You though, probably want to take a different path.

    So I may not have solutions.

    If you need additional help, you may want to find the

    Form1.Designer.vb (the InitializeComponent part)

    and post it, as well as your form1.vb code for

    others to see what you are up to.

    Good luck!



  • robertje

    Just add a label to form1 and make it's text

    about 10 blanks. Then:

    Public Class Form1

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    MsgBox("test")

    End Sub

    End Class



  • AshishGupta

    I just get a flat, grey, simple, clickape rectangle....but not transparent...
  • Mantorok

    I am showing you the 'InitializeComponent' partial class first.

    That part is normally created automatically as you add things

    to your form.

    The Form1 code (the code the programmer normally

    types) is the last little part at the end.



  • barkingdog

    Instead of using a button just use the underlying control, and when the user clicks check if it's in the wanted rectangle area.

    if rectangle.contains(x,y) then

    doStuff

    end if



  • laboremus

    lol, I like your thinking, but too bad it doesn't work...(label thing)

    Its the same problem with the button-IT STILL SHOWS UP

    Please help...


  • Biju S Melayil

    Tall dude, are you sure this is for VB express edition there are many errors...

    Could someone please help me I still cant get this to work!!!!


  • Inivsible Button