PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Dynamically created TextBox: Caret can be placed in middle of theblank area!
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Dynamically created TextBox: Caret can be placed in middle of theblank area!
![]() |
Dynamically created TextBox: Caret can be placed in middle of theblank area! |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
VS2008, VB, .NET 3.5
When I create a TextBox in Designer, then at runtime wherever I click, the caret is placed at the end of the text the box actually contains. But when I create a TextBox dynamically, the caret stays wherever I clicked, int he middle of nowhere. Is this a property that defaults different in Designer or at runtime, or is it a bug? My code: Dim tb As System.Windows.Forms.TextBox = New System.Windows.Forms.TextBox tb.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top tb.Multiline = True tb.Height = 100 tb.Text = "Yo Man" panelDocument.Controls.Add(tb) |
|
|
|
#2 |
|
Guest
Posts: n/a
|
On May 22, 9:24 pm, "Steve Gerrard" <mynameh...@comcast.net> wrote:
> Jeannot wrote: > > VS2008, VB, .NET 3.5 > > When I create a TextBox in Designer, then at runtime wherever I click, > > the caret is placed at the end of the text the box actually contains. > > But when I create a TextBox dynamically, the caret stays wherever I > > clicked, int he middle of nowhere. > > > Is this a property that defaults different in Designer or at runtime, > > or is it a bug? > > > My code: > > > Dim tb As System.Windows.Forms.TextBox = New > > System.Windows.Forms.TextBox > > tb.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or > > AnchorStyles.Top > > tb.Multiline = True > > tb.Height = 100 > > tb.Text = "Yo Man" > > panelDocument.Controls.Add(tb) > > It doesn't happen that way at all on my machine. I pasted this code, assuming > panelDocument is a Panel control. Works fine, produces a perfectly normal > TextBox, caret behaves as you described for the designer version. > > What else are you doing? Somewhere else in your code lies the answer... You are correct that the parent is a Panel. tb is not referred to anywhere outside of the code you see, except for setting Top-Left-Width You are on VS2008, VB, .NET 3.5 ? I'll try "Name"ing it, and swapping the order in which I set the properties. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
On May 23, 10:09 am, "Steve Gerrard" <mynameh...@comcast.net> wrote:
> Jeannot wrote: > > >> What else are you doing? Somewhere else in your code lies the > >> answer... > > > You are correct that the parent is a Panel. > > tb is not referred to anywhere outside of the code you see, except for > > setting Top-Left-Width > > You are on VS2008, VB, .NET 3.5 ? > > Actually I'm on VS2005, VB, .NET 2.0. Can't believe that would make a > difference, though. > > It's a mystery. Are you testing this is a small app by itself? It might be worth > it, to help isolate the issue. Okay, problem solved. Thanks for your help Steve. My problem was self-inflicted during a senior moment. It is very unlikely that others will see the same problem, so humiliating myself by describing it would not help anyone. |
|
|
|
#4 |
|
Guest
Posts: n/a
|
"Jeannot" wrote: > Okay, problem solved. Thanks for your help Steve. > My problem was self-inflicted during a senior moment. > > It is very unlikely that others will see the same problem, so > humiliating myself by describing it would not help anyone. maybe unlikely, but not impossible. in fact, i have the exact same problem but i have absolutely no clue how to turn off this feature. so it would be great if you could please share your solution here. regards, vlad |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

