Emil Dumbazu
Emil Dumbazu

Reputation: 662

Put a value in a read-only textbox vb.net

I have a form with many textboxes. I would like to disable the operation of user interaction with 2 or more textboxes but i would like to assign some text to it. I cannot figure it out a way to do it ...

I have the following code:

 If tablead.Rows(0)(4) = True Then
        TextBox2.Text = "0"
        TextBox2.ReadOnly = True
        TextBox2.Text = "0"
 End If

When i run it the textbox goes "read-only" but the value 0 is not shown. Why ?

Upvotes: 1

Views: 7661

Answers (1)

JaggenSWE
JaggenSWE

Reputation: 2106

You're doing it somewhat right, however you need to provide more code.

The

If tablead.Rows(0)(4) = True then
   TextBox2.Text = "0"
   TextBox2.ReadOnly = True
End If

is sufficent to achieve what you're aiming for, but for some reason it never fires the event that you've put this code in. Do have a look and see if there's something else happening that makes it jump this code.

Upvotes: 2

Related Questions