Hi there,
I'm designing a winforms app in VB.NET 2.0 and have a textbox control and
also some toolbar buttons. I want to have it such that when the user clicks a
toolbar button, some predefined text - such as the date - is inserted into
the textbox at the point where the caret is. (It's assumed that the user will
be typing and then click the toolbar button.) From my research the textbox
control doesn't seem to support any method of querying the position of the
cursor. I've found documentation on pulling in the function "GetCaretPo s"
from user32.dll and using that, but those examples seem to return coordinates
of the caret and not a linear position in the text. Is there a good way
anyone can think of to achieve this?
Thanks...
-Ben 4 19377
Look at the 'SelectionStart ' property.
--
Terry
"Ben R." wrote: Hi there,
I'm designing a winforms app in VB.NET 2.0 and have a textbox control and also some toolbar buttons. I want to have it such that when the user clicks a toolbar button, some predefined text - such as the date - is inserted into the textbox at the point where the caret is. (It's assumed that the user will be typing and then click the toolbar button.) From my research the textbox control doesn't seem to support any method of querying the position of the cursor. I've found documentation on pulling in the function "GetCaretPo s" from user32.dll and using that, but those examples seem to return coordinates of the caret and not a linear position in the text. Is there a good way anyone can think of to achieve this?
Thanks...
-Ben
Thanks!
textBox1.Text = textBox1.Text.I nsert(textBox1. SelectionStart, "Test");
worked beautifully...
-Ben
"Terry" wrote: Look at the 'SelectionStart ' property. -- Terry
"Ben R." wrote:
Hi there,
I'm designing a winforms app in VB.NET 2.0 and have a textbox control and also some toolbar buttons. I want to have it such that when the user clicks a toolbar button, some predefined text - such as the date - is inserted into the textbox at the point where the caret is. (It's assumed that the user will be typing and then click the toolbar button.) From my research the textbox control doesn't seem to support any method of querying the position of the cursor. I've found documentation on pulling in the function "GetCaretPo s" from user32.dll and using that, but those examples seem to return coordinates of the caret and not a linear position in the text. Is there a good way anyone can think of to achieve this?
Thanks...
-Ben
"Ben R." <be**@newsgroup .nospam> schrieb: I'm designing a winforms app in VB.NET 2.0 and have a textbox control and also some toolbar buttons. I want to have it such that when the user clicks a toolbar button, some predefined text - such as the date - is inserted into the textbox at the point where the caret is.
\\\
Me.TextBox1.Sel ectedText = "Hello World"
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
This is much easier than what I had devised using the selectionstart
property, which required me to do some math for where to insert and where to
place the cursor after. Thanks!
-Ben
"Herfried K. Wagner [MVP]" wrote: "Ben R." <be**@newsgroup .nospam> schrieb: I'm designing a winforms app in VB.NET 2.0 and have a textbox control and also some toolbar buttons. I want to have it such that when the user clicks a toolbar button, some predefined text - such as the date - is inserted into the textbox at the point where the caret is.
\\\ Me.TextBox1.Sel ectedText = "Hello World" ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas |
last post by:
Hi there,
I'd like to insert a text into a textarea at the current cursor position
when you click on a button, but I only found out how to insert a text at
the end of the textarea. Is it possible to insert text at cursor position
and if it is, how can I do it?
Thanks for any help
|
by: Lloyd |
last post by:
I am trying to insert text in a text area. I need to insert one set of
values on the left side of the text area and have corresponding values
on the left side of the text area in an even column.
How do I specify which column in a text area to insert text?
document.textform.textarea.col.value == "put it here"
If not possible, then can I insert text left aligned then insert text
right aligned on the same row?
Lloyd
*** Sent via...
|
by: Carlos Lozano |
last post by:
I need to merge the content of two richtextboxes.
It can not be accomplished using the RichtTextBox.Text field because all
format will be lost. So it has to be done using the RichtTextBox.Rtf field,
but I loose part of it as follows:
private void MergeRtf()
{
// having the RichTextBox controls.
|
by: Matt Tapia |
last post by:
Is there a way to insert text into a multi-row textbox where the cursor
position is at in the multi-row textbox?
Just wondering
|
by: Matt Tapia |
last post by:
Is there a way to insert text into a multi-row textbox where the cursor
position is at in the multi-row textbox?
Just wondering..I was told I could use the SelectedText property however I
get this error:
'SelectedText' is not a member of 'System.Web.UI.WebControls.TextBox'.
Thanks!
| |
by: Lelle |
last post by:
Hello !
how can i insert text containg code examples from a textbox into a database
using SQL insert statment.
i have no problem to just add text that dont contains code and script
examples or the illegal chars for the insert command
is it possible to encasulate the text/string so the server doesnt reads the
string as a command?
|
by: jonathandrott |
last post by:
hi, i'm trying to insert a textbox value into a access database. i get
an error: 'Error: no value given for one or more required parameters.'
nothing is set to be required in the db. is there something wrong
with my syntax?
Dim formConn As OleDb.OleDbConnection = New OleDb.OleDbConnection
Try
formConn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\CustomerInfo.mdb;"
|
by: azam841 |
last post by:
Can We Insert A Textbox Into Listbox In Asp.net
|
by: Jeannot |
last post by:
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:
|
by: midhun singh |
last post by:
Hi all,
I have a little bit of a problem figuring out how to insert a textbox string from a VB.Net Windows form onto a Crystal Report. I have search through many articles and manuals for a way to do this, but have not managed to find anything. I am sure this is possible. I need this to be inserted into the title of my report, pending on the selection criteria chosen for the specific report. Any help on this matter would be appreciated...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |