473,378 Members | 1,417 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,378 software developers and data experts.

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 1358
textBox.SelectionStart

-vJ

"Hector Martinez" <an*******@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.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.SelectionStart

-vJ

"Hector Martinez" <an*******@discussions.microsoft.com> wrote in message
news:BE**********************************@microso ft.com...


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

TextBox.SelectionStart 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
/WindowsUserInterface/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("user32.dll")]
public static extern bool GetCaretPos(ref Point pt);

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

if (GetCaretPos(ref 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
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...
7
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...
19
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...
13
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.