-
September 15th, 2011, 03:16 PM
#1
Strange problem with dynamically created control
Hi,
I have a strange behavior with a dynamically created TextBox-Control. The control is created in the handler of the Load-event of a dialog-form like this:
txtTitel = New System.Windows.Forms.TextBox
txtTitel.Name = "txtTitel"
txtTitel.BackColor = Color.White
txtTitel.ForeColor = Color.Blue
txtTitel.Location = New System.Drawing.Point(106, 185)
txtTitel.Size = New System.Drawing.Size(406, 20)
txtTitel.TabIndex = 7
txtTitel.Text = ""
Me.Controls.Add(txtTitel)
Now the situation is, that in most cases it works fine. But a few of my customers report that the TextBox not appears on their dialog - it's not there! That's all, nothing more to say.
I appreciate any advice, hints or reports about known pitfalls with dynamically created controls which could explain this (sometimes) strange behavior and how I could fix it (I have to create this control dynamically due to some reasons).
BTW: The program is built with Visual Basic 2005. And the customers with trouble are spread about the OS's (XP, Vista, 7).
Many thanks in advance
Physicus.
-
September 15th, 2011, 04:05 PM
#2
Re: Strange problem with dynamically created control
I do not know if it would make a difference but I always set the visible property to true and have never saw an issue like you describe.
Always use [code][/code] tags when posting code.
-
September 15th, 2011, 11:50 PM
#3
Re: Strange problem with dynamically created control
Hello DataMiser,
thank you for your reply and your advice.
Member visible = True should be the default when creating a new control. But you may be right - setting it explicitely to True would be the save way.
I also thought about doing the creation in an other handler but I think Load() is the best place, isn't it?
Thank's for your answer.
Physicus.
-
September 18th, 2011, 03:32 PM
#4
Re: Strange problem with dynamically created control
I have seen this before, on XP believe it or not!
I always, always use .Visible = True.
Do not ask me why this behaviour happens, it just does
Where to put probably depends on your situation. What I do is to have a separate sub that creates the control(s). This why the Form_Load is not so clogged with the creation of the control.
-
September 24th, 2011, 07:29 AM
#5
Re: Strange problem with dynamically created control
Hi,
I now added .visible = True and hoped that the problem vanished. It seemed so. A dozen customers reported it works fine. But this morning again a customer emailed me the same old problem: text box isn't there!
It's really annoying! Does anybody know a solution???
Many thanks in advance
Physicus.
-
September 25th, 2011, 12:31 PM
#6
Re: Strange problem with dynamically created control
Check his resolution. You are hard coding, rather than calculating the screen size first
-
September 29th, 2011, 08:24 AM
#7
Re: Strange problem with dynamically created control
@dglienna: This should not be a problem at least for two reasons:
1.
It is the same coding as in the xxx.Designer.vb-Files produced by the form-Editor.
2.
My coordinates are within 640 x 480 and I am pretty shure my customer works with a higher resolution ;-)
Best regards,
Physicus.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|