deleting a line from a multiline textbox

H

Harry Hudini

I have a multiline textbox and want to be able to allow the user to position
the cursor in a line of the textbox, then click on a Remove button to remove
the line which the cursor is on. Thing is, i would need to know how to find
the line the cursor is on.

I can deleted the selected text, but i dont want the user to have to select
any text.

Can this be done ? Is there anyway to find the line number of the cursor
within a text box ?

Olly

--
________________________________________________
ADSSupport.net
http://www.adssupport.net
Dedicated free Active Directory ServicesT support

email: oliver.marshall@[email protected]
 
F

Fergus Cooney

Hi Harry,

TextBox can't do this on its own but RichTextBox can. If you're ok with
your Users using RTB, you can have:

MousePos = ...
CharPos = RTB.GetCharIndexFromPosition (MousePos)
LineNum = RTB.GetLineFromCharIndex (CharPos)
RTB.Lines.RemoveAt (LineNum)

Regards,
Fergus
 
H

Harry Hudini

Thanks for this. I have a questions.

This would appear to remove the line of text at the location of the mouse
pointer, rather than the text cursor. Also, assuming that it doesn't work
that way, how do i get the mouse postion on the first line ??

Also, the RemoveAT method isnt present in the rich text control.

Thanks for the help though :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top