473,809 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another TextBox Question


I need to know the position of the cursor inside the TextBox. How Can I do that

Thanks in advantage...
Nov 15 '05 #1
2 1377
textBox.Selecti onStart

-vJ

"Hector Martinez" <an*******@disc ussions.microso ft.com> wrote in message
news:BE******** *************** ***********@mic rosoft.com...


I need to know the position of the cursor inside the TextBox. How Can I do that?
Thanks in advantage...

Nov 15 '05 #2

textBox.Select ionStart

-vJ

"Hector Martinez" <an*******@disc ussions.microso ft.com> wrote in message
news:BE******* *************** ************@mi crosoft.com...


I need to know the position of the cursor inside the TextBox. How
CanI do that?

TextBox.Selecti onStart returns start position of the selection. But the
caret (cursor position inside the textbox) may be outside the selection.
If you interested in finding out where the caret (cursor) is, then you may
need to use the extern function in user32.dll called GetCaretPos.

Here is the msdn help site on GetCaretPos.
http://msdn.microsoft.com/library/de...us/winui/WinUI
/WindowsUserInte rface/Resources/Carets/CaretReference/CaretFunctions/GetCare
tPos.asp

Sample code. (Here is what i think it would look like, i have not tried
this code out.)

using System.Runtime. InteropServices ; // you have to include this to use
the extern method.

class myClass
{
[DllImport("user 32.dll")]
public static extern bool GetCaretPos(ref Point pt);

public void MyMethod ()
{
Point pt = new Point(0, 0);

if (GetCaretPos(re f pt))
{
MessageBox.Show ("x = " + pt.X.ToString() + " y = " +
pt.Y.ToString() );
}
}
}
Hope this helps.
--
Adrian Mascarenhas, Developer Division

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 15 '05 #3

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

Similar topics

1
2619
by: Tim | last post by:
Hello All, Sorry for the newbie question, but here goes: I have a form named MainForm (namespace=MyFormProject, class=MainForm). In that form is a textbox tbOutput. This is a multi-line textbox that I want to send values to. I then have another function named ReadData (namespace=OtherName, class=OtherClass). I have a while loop that reads data and I want this function to be able to AppendText to the tbOutput textbox. I can't seem to...
7
6215
by: Dave | last post by:
I have two forms, Form1 and Form2. From Form2, how do I reference the value in a control on Form1? Or perhaps a more specific question: Form1 contains a textbox with the value of 10. This form is hidden. Form2 is active and a user enters a value of 2 into a blank text box. How can I add this value to the textbox in Form1 so that when Form1 is displayed it's textbox displays 12? I probably have the wrong mindset here; I'm thinking...
19
1089
by: Maarten | last post by:
i'm making a form where you can add textboxes with a button. the max number of textboxes to add is 100 but i also must create an array of al thes textboxes, is there a way of creating an array of thextboxes that aren't created yet. fot exapmle Dim delayarray(100) As TextBox(100) <--------------- this won't work ofcourse
13
2463
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
3
2075
by: vzrandom | last post by:
Hi guys, I have one easy question for you. I have class with public static variable. I enter value in one form (in this public static variable) and when I passed it to another form in textbox I can't see the value until I try to write something in this textbox and then the value it self is locked and can't be changed. In mentioned textbox I'm using following code: textBoxExample.Text = Class1.variable1; what I'm doing wrong?
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
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...
0
9200
agi2029
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...
0
5550
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...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
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...

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.