4 Replies - 706 Views - Last Post: 10 September 2012 - 01:14 AM Rate Topic: -----

#1 Vishal1419  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 19-May 12

Custom Control in vb.net

Posted 07 September 2012 - 05:38 AM

Hello Friends,

I have got a problem

I added a Textbox and a label to custom control design view

The Image is as shown below

Attached Image

When Mousedown on label The textbox font is "Microsoft Sans Sherif"

When MouseUp on Label the Textbox Font is "Wingdings"

and Password Character is "l"

Everything works fine

Just I did not get the text property of textbox at design time. How Can I get it?

Thanks for any help.

This post has been edited by Vishal1419: 07 September 2012 - 05:41 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Custom Control in vb.net

#2 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: Custom Control in vb.net

Posted 07 September 2012 - 07:30 AM

You do realize this is not in any way secure, right?
All someone has to do is copy/paste the text from the textbox then change the font back to something normal and the password is visible.

Quote

Just I did not get the text property of textbox at design time. How Can I get it?

If this is a custom control class, or even just a UserControl then you have to create a .Text property (that gets and sets the .Text of the TextBox). Since the Textbox is a layer deeper than the userControl you have to create a property to pass that info up/down to the TextBox.

Visual Studio won't telepathically know you want to have the .Text property of the TextBox bleed through to the UserControl.

If it is a PasswordBox and not a textbox then there isn't a .Text property - there is a .password property instead
Was This Post Helpful? 1
  • +
  • -

#3 Vishal1419  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 19-May 12

Re: Custom Control in vb.net

Posted 09 September 2012 - 10:48 PM

Thanks for the reply
I have to Override the text property
Its working now

Here is the code
<Category("Custom Properties"), Browsable(True)> _
    Public Overrides Property text() As String
        Get
            Return txtPassword.Text
        End Get
        Set(ByVal value As String)
            txtPassword.Text = value
        End Set
    End Property

Was This Post Helpful? 1
  • +
  • -

#4 Vishal1419  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 135
  • Joined: 19-May 12

Re: Custom Control in vb.net

Posted 10 September 2012 - 12:59 AM

Hello friend,
I got another problem
Basically I have two textboxes viz. txt1,txt2 and a button on the form btn1
I have manyother fields in the form though I am taking these two textbox in account to make understand my problem more clearly
txt1 and txt2 are both the password textbox that i have created earlier and mentioned in the above posts

private sub btn1_Click(byval sender as object, byval e as system.eventargs) handles btn1.click
   If txt1.text = txt2.text then
      'Passwords match and save the password to the database
   else
      'Passwords does not match
   end if
end sub


Upto here it works fine

Now the problem is that when I retrieve this password from database to txt1, I cant see anything written in txt1. I have checked my database, there I get the password.

What might be the problem any Ideas !!!!!!!!!!!!!!!!!!

This post has been edited by Vishal1419: 10 September 2012 - 01:01 AM

Was This Post Helpful? 0
  • +
  • -

#5 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 36
  • View blog
  • Posts: 710
  • Joined: 09-May 09

Re: Custom Control in vb.net

Posted 10 September 2012 - 01:14 AM

perform and simple test, assin the retrieved value to a string. This will allow you to see if you are indeed retrieving the value or you have an issue with the password control coding.

kevin
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1