473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dynamically created TextBox: Caret can be placed in middle of theblank area!

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)
Jun 27 '08 #1
4 1753
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...
Jun 27 '08 #2
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.
Jun 27 '08 #3
On May 23, 10:09 am, "Steve Gerrard" <mynameh...@comcast.netwrote:
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.
Jun 27 '08 #4

"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

Jun 30 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example...
4
by: ray well | last post by:
i have a text box with limited space that gets loaded from database records. the important info is at the bottom of the text, which requires scrolling to get to it, which is a pain. is there a...
1
by: Chien Lau | last post by:
Hi, When a user clicks a TextBox on a modal form, the caret immediately moves to the clicked location within the existing text. On a non-modal form, the user's TextBox click sets the focus...
3
by: Forconi Boris via .NET 247 | last post by:
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created...
1
by: José Joye | last post by:
Hello, I'm playing around with dynamically loading user controls ...and having problems I created a really simple userControl (in fact contains a plain text box) and placed it into the...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
4
by: Fool | last post by:
Hi, I want a rich textbox that dynamically highlights particular words immediately after they are typed. Just looking for some general tips... I tried putting some code in a sub that handles...
1
by: lolly | last post by:
hi i recently used a virtual keyboard from www.codeproject.com/jscript/jvk.asp. However this part of the code function keyb_callback(ch) { var text =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.