View Single Post
  #2 (permalink)  
Old 04-06-2008, 07:43 AM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: London, England
Posts: 7,055
Last Blog:
Web slideshow in JavaS...
Credits: 1,024
Rep Power: 58
Xav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to beholdXav is a splendid one to behold
Send a message via MSN to Xav
Default Re: Peculiar UI Problem Needs Tackling

I don't know much about hexadecimal bytes, and so Problems 1 and 3 I cannot help you with. However, Problem 2 is a general programming task, and it shouldn't be much of a hassle.
You need to load up the event that occurs whenever the user selects some text. This may be something like SelectionChanged(), I can't remember the details off the top of my head!
In this, here's what you do:

1. Transfer the caret position across using textbox.SelectionStart(). This returns the index of the cursor in the textbox.
2. Transfer the number of selected characters across using textbox.SelectionLength(). This returns the length of the selection.

Here's the code for the txtASCII_SelectionChanged() event:

Code:
txtHex.SelectionStart = txtASCII.SelectionStart; //Place cursor in right place.
txtHex.SelectionLength = txtASCII.SelectionLength; //Select correct number of characters.
txtHex.ScrollToCaret(); //If there is a lot of text, scroll the textbox to where the selection is.
In the txtHex_SelectionChanged() event, do the opposite, assigning the Selection values to the txtASCII textbox. This way, the selection will always be synchronised. You might want a try/catch block in case there is an error or something.

Xav
__________________
[TRUTH] TcM is the best moderator ever! [/TRUTH]
"Valid XHTML is like sex - everybody claims to have the same goal, but everybody has their own tricks and results vary wildly."

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Xav; 04-06-2008 at 07:44 AM. Reason: Spelling
Reply With Quote