Is it possible to hijack text box functionality for custom control

I am working on a custom control, an extension of Panel which draws a series 
of rectangles in a flow chart. Each rectangle has a title and the ideal 
approach would be to allow the user to edit the title by simply clicking it.

Obviously I could hook up a rename dialog to a context menu which would be 
easy but it is a bit more tedious to the users so I am hoping I can 
accomplish this the ideal way.

Textbox functionality does not look simple though so I'd hate to recreate it 
for my control. Yeah handling the keyboard events to show what the user types 
is not hard but I am not sure how the flashing cursor would play out (not 
talking about the mouse cursor, but the blinking cursor which indicates you 
are editing text)

So one thing I was hoping I can do is somehow hijack the textbox's 
functionality, like creating a textbox which would be superimposed on the 
label which would be editted. Can I do that? I have been trying a few things 
but so far no dice. 

Even just a broad description of how to do this would be grateful
0
Utf
11/13/2009 4:55:02 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

4 Replies
881 Views

Similar Articles

[PageSpeed] 29

On 13/11/2009 in message 
<75C40650-5AB6-42B7-AA97-994C33C95D6A@microsoft.com> trant wrote:

>So one thing I was hoping I can do is somehow hijack the textbox's
>functionality, like creating a textbox which would be superimposed on the
>label which would be editted. Can I do that? I have been trying a few 
>things
>but so far no dice.
>
>Even just a broad description of how to do this would be grateful

I saw an in place editable List View that did something similar.

What it did was trap a double click, put a Text Box in place over the 
existing text (sizing as appropriate) and copy the text into itself. The 
Text Box itself was then disposed or hidden on picking up the Enter Key or 
when it lost focus. It then copied its text back into the List View. You 
could also trap the Escape key to dispose/hide the Text Box and discard 
its contents.

-- 
Jeff Gaines Dorset UK
All things being equal, fat people use more soap
0
Jeff
11/13/2009 5:24:18 PM
"Jeff Gaines" <jgaines_newsid@yahoo.co.uk> wrote in message 
news:xn0ghlwxu8v7og4002@msnews.microsoft.com...

> What it did was trap a double click, put a Text Box in place over the 
> existing text (sizing as appropriate) and copy the text into itself.

What Jeff is describing is pretty much the most common way of doing this 
without rolling your own text box. You can also turn off the border so that 
it looks like you're typing directly into the rectangle. 


0
Jeff
11/13/2009 6:49:32 PM
Jeff Gaines wrote:
> On 13/11/2009 in message 
> <75C40650-5AB6-42B7-AA97-994C33C95D6A@microsoft.com> trant wrote:
> 
>> So one thing I was hoping I can do is somehow hijack the textbox's
>> functionality, like creating a textbox which would be superimposed on the
>> label which would be editted. Can I do that? I have been trying a few 
>> things
>> but so far no dice.
>>
>> Even just a broad description of how to do this would be grateful
> 
> I saw an in place editable List View that did something similar.
> 
> What it did was trap a double click, put a Text Box in place over the 
> existing text (sizing as appropriate) and copy the text into itself. The 
> Text Box itself was then disposed or hidden on picking up the Enter Key 
> or when it lost focus. It then copied its text back into the List View. 
> You could also trap the Escape key to dispose/hide the Text Box and 
> discard its contents.

For what it's worth, I use this technique myself, and it works fine.  In 
one example in my own case, it's an always-existing Label in a Form 
edited using a TextBox, so I just have a dedicated TextBox aligned just 
right with the Label.  I show/hide the Label/TextBox as appropriate to 
the user's actions, and handle Enter and Escape keys as Jeff suggests.

For this particular scenario, where the text to be edited can be 
positioned arbitrarily, and there can be arbitrarily many of them, it 
may make more sense to have a single TextBox that is never disposed, 
positioned and shown when editing needs to happen, and then hidden again 
when the user's done.

Pete
0
Peter
11/13/2009 6:52:52 PM
Thank you gentlemen for the advice!

Here is the code I wound up doing to accomplish the in place editting:

TextBox editbox;

// during form init
editbox = new TextBox();
editbox.Visible = false;
editbox.KeyUp += new KeyEventHandler(editbox_KeyUp);
this.Controls.Add(editbox);     

//my rectangle are encapsulated into objects called Node, I keep ref to one 
currently being editted:
Node editnode;

// methods to handle begin/end of editting
void BeginEdit(Node node)
 {
            editnode = node;
            editbox.Visible = true;
            editbox.Bounds = editnode.Area;
            editbox.Text = editnode.Title;
            editbox.Focus();
            editbox.SelectAll();
}

void EndEdit(bool save)
{
            editbox.Visible = false;
            if (save)
            {
                editnode.Title = editbox.Text;
                editnode.ReDraw();
                this.Invalidate();
            }
            editnode = null;
            editbox.Text = "";            
}

// key event handle to capture Enter/Esc
void editbox_KeyUp(object sender, KeyEventArgs e)
 {
            if (e.KeyCode == Keys.Enter)
            {
                EndEdit(true);
            }
            else if (e.KeyCode == Keys.Escape)
            {
                EndEdit(false);
            }
 }

then I also call BeginEdit on MouseUp event after calling a EndEdit if the 
editbox was already visible


0
Utf
11/13/2009 9:15:02 PM
Reply:

Similar Artilces:

Word hangs when I try to edit text
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I can open documents, but when I select text to edit, try to add a return or a shift, it hangs. All I can do is force quit. It's really annoying! All the updates are up-to-date, and it worked just fine the other day. <br><br>What's going on? And how can I fix it? <br><br>Thanks! That sounds like a corrupt document. Try saving it as a web-page, then quit, re-open, and re-save as a Word document. If it hangs during the Save As, try a Maggie: The Maggie: 1. Create a ne...

forecast function help
This might seem a bit newbie but im having trouble with the forecas function. Say for example i have a collection of data for sales of each item ove a number of years: item 2000 2001 2002 2003 1 3 4 5 2 4 3 2 3 2 2 4 4 3 1 5 5 4 1 6 6 2 2 4 i am asked to forcast the values for the year 2003. I have read an looked at many examples on how to do this and still can't work ou where to start? Any help would ...

caption, text box, and frame
I inserted a picture (a bitmap), cropped and sized it to fill the page from side to side, and positioned it 1.5" from the top "margin" so that it would be at the top of the text area. I then clicked on Insert Caption and got the usual panel offering "Figure 1" as its label. Instead of simply inserting a paragraph in Caption format as usual, it inserted a text box with the caption label in it. When I typed the content of the caption, the following body text reduced to a single line. Dragging the picture's anchor to a different paragraph made whole paragrap...

Combo Box problem 05-07-07
I have a combo control on a form that has when I select a value the form reverts to the first record it doesn't stay with the current record. I have a NotinList procedure that opens another form to enable the user to add to the list of values in the combo control and when I close this second form the new value is recorded but again the form goes to the first record and doesn't stay with the current one. Anyone any ideas where I can start looking for the reason why this happens? Thanks Tony Tony Williams wrote: > I have a combo control on a form that has when I select a val...

Need to set up a slide with 4 text boxes on same page.
Want to end up with 4 "bulleted" boxes that I can to show 4 strategies and associated task on same page. Also, if possible have each one drop in individually to allow flow conrol for the presentation Are you asking a question about how to do that or having trouble with part of that? If the former, just create four separate text boxes with bulleted text, you are not limited to only one text box per slide. Use the Custom Animation, Effects Options, Text Animation settings to control the entrance of the bullet points. Since you didn't say what version of PowerPoi...

Customer Address Help
Hi, I was wondering if anybody knew of a way to run a customer report that invluced the customers address, city, state, and zip in it. I am not very familiar with crystal reports, so if there is another way that would be awesome. Thanks, -Bill H On CustomerSource there is a section called the "Report Library"- I think it's under downloads. In the RMS Report Library MS has provided several new or modified reports, including one with customer address. On Sat, 17 Jul 2004 08:40:10 -0700, Bill H <bill@platinumpools.com> wrote: > Hi, I was wondering if anybody k...

Calender function
I want to be able to insert a drop down function in a cell in Excel that when I click on the drop down arrow, I get a monthly calender to pick dates from instead of typing them in. This feature exists in MS Project. Maybe you like this http://www.rondebruin.nl/calendar.htm -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "John Welcher" <john.welcher@owenscorning.com> wrote in message news:057201c3a252$339c5fd0$a401280a@phx.gbl... > I want to be able to insert a drop down function in a cell > in Excel that when I click on the drop down ar...

Add Text Field Columns
PFDB: IIf(Nz([PFDirect])+Nz([PFBulk])=0,"",Nz([PFBulk])+Nz([PFDirect])) I have two fields both of which are text. When I try to add them as above, I get a concatenated result, not the sum. How does one add them? -- On Fri, 18 May 2007 17:38:49 -0600, bw wrote: > PFDB: IIf(Nz([PFDirect])+Nz([PFBulk])=0,"",Nz([PFBulk])+Nz([PFDirect])) > > I have two fields both of which are text. When I try to add them as above, I get a > concatenated result, not the sum. How does one add them? How does one add "This is text." + "this is also text&qu...

how to change the icon text
To all, What event to I do to handle when my app get iconified? I Need to set the window text for my icon differently than my app title bar text. When I run my app, the window text for the app title bar is "foo", when the user iconifies the app, I want the icon text to be "bar". How do I do that? Thanks for the help, Reza Take a look at CWnd::OnSysCommand. SC_RESTORE and SC_MINIMIZE is what you want to look for in this method. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "reza razavipour" <rrazavipour@stbernard.com> wrote in message news:uK18XkXH...

automatically sizing text with graphs
hi, is there a way to make the text in my charts size proprotionally with the graphs when i move them to another location (eg: a different sheet or chart)....I seem to have a problem with the way the graphs shrink but the text retaining their original size after i move them. -- Shoque ------------------------------------------------------------------------ Shoque's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=36320 View this thread: http://www.excelforum.com/showthread.php?threadid=566948 Right-click on the axis labels and choose Format Axis. Go to the Fon...

Visio File Summary Dialog Box is showing wrong file name and size
Hi all, I am using Visio 2003 ActiveX Control in my application using VB.NET 2005. I am calling "visCmdFileSummaryInfoDlg" Command to open File Summary Dialog Box. Dialog Box is open successfully but it always showing Template file size instead of open file size in General Tab. The information it shows is: Type: Microsoft Visio Drawing Location: Size :(928 bytes) Based on: Template - ValueStreamMap.vst Can any one let me know about any property or way so that it shows correct file size? Thanks Asif Can we assume that the new drawing has been saved to disk before you call th...

customizing the task list print options
I'd like to print my "tasks" list but with the complete Note field included. How does one accomplish that? I'm surprised it isn't a standard form provided in Outlook. -- ------------ Michael Bierman ...

Using a Text / Data output as a cell reference
I am trying to use the end of a column as a divisor and need to convert what i guess is text into an actual cell reference if possible. In column A, say there are 13 data points ending at cell A13. I then try to turn that into a cell reference with the formula ="A"&TEXT(COUNTA(A1:A13,),"0") I put this formula in B1 the output of this is then A13 what i need this to do, is be able to divide any cell by A13. The reason I am going through all this trouble is that there are many columns and each has a different # of data points. I hope this is somewhat clear. Thanks ...

TEXT TO SPEECH CHANGES
Currently my text to speech config reads ONLY LETTERS if the letters are CAPITALs(IE when it come to the word ABLE, it speaks A B L E how can I change the setting to make the system say "able" Thanks Enter this small macro: Sub Macro1() For n = 1 To 100 Cells(n, 1).Speak Next n End Sub And it should "say" whatever text you enter in A1 thru A100 -- Gary's Student "pcor" wrote: > Currently my text to speech config reads ONLY LETTERS if the letters are > CAPITALs(IE when it come to the word ABLE, it speaks A B L E > how can I change...

Migration: Migrated custom fields can't sync with plan
We migrated a set of enterprise global fields from 2003 to 2007. However, some of the post migration changes to these fields can't be reflected into project professional for all plans. Example, we have a project outline code in 2003 called Portfolio, which is a hierarchical set of values. In 2003, we allowed selection of non-leave node and didn't allow multi-selection. After migration, we changed the settings of the field to allow only leave node and multi-selection. However, these changes are neither picked up by migrated project plans nor newly created project plan....

Set value of const member variable in Init() function?
Is there a method for setting the value of a const member variable in an Init() function when the value is unknown in the constructor? TIA, Harvey "Harvey" <harveyab@juno.com> wrote in message news:1172562585.493563.230590@h3g2000cwc.googlegroups.com... > Is there a method for setting the value of a const member variable in > an Init() function when the value is unknown in the constructor? I don't believe so. But be careful of the difference between const int x=1; and const char *pszString; pszString = ... The latter is ok as the pointer is not const - th...

Bug in excel fundamantal add-function
Hi Where can I report a bug in excel? OK I try this group. Try this A1 = -621,2 A2 = 2 A3 = 1 A4 = -540,2 A5 = 175 A6 = 986,4 A7 = SUM(A1:A6) A7 must be 3 - but try to have 13 decimals...!!! is this a BUG? I think so Using Danish XP and danish 2002 SP3 No, it's not a bug. It's a "feature" of XL using IEEE double precision floating point math. Most numbers can't be exactly represented in a finite number of binary digits, just as 1/3 can't be exactly represented by a finite number of decimal digits. You can use ROUND() to round to zero if it's necessary. ...

how do I get the if function to return a blank cell, not 0?
I am trying to create a chart from a series that contains data for each month. The series is calculated on other worksheets and copied to the worksheet containing the chart. I would like to have the cells for the months that have not been updated yet (now is January, there are 0' in all cells for Feb-Dec) to be blank (to create gaps in the chart) not 0's. Can this be done? Unfortunately, what you want, and what many of us have requested but doesn't exist, is a worksheet function like BLANK() or NULL(). The best we can do is use NA() in a chart's data source, which is...

How do I extract text from a consecutive run of 15 pgs in Publishe
The original text was pasted in from a document. Now I want to extract the text to a Word document again so that I can get someone else to update it. 2007 If the text boxes are connected, you could try Edit | Edit Story in Word -- ~~~~~~~~~~~~~~~~~~ Rob Giordano Microsoft MVP Expression "Suebriquet" <Suebriquet@discussions.microsoft.com> wrote in message news:31CB7416-D6DB-4047-B8A6-AB811624E37C@microsoft.com... > The original text was pasted in from a document. Now I want to extract the > text to a Word document again so that I can get someone else to update...

How to save the value in the CEdit control to a text file?
Im generating a random number to the CEdit control and now i want t save all of this value to a text file. I dont know to code it in the way of MFC. I hope whose know it can send me the soding cause im running out the time to do my project thanks You can use GetWindowText to get its contents and then use CStdioFile class to write the text. MSDN has enough documentation on this. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "TLee" <anonymous@discussions.microsoft.com> wrote in message news:F730B5D6-85F7-45D9-80D9-C43598FA47B6@microsoft.com... | Im generating a random numbe...

excel function search
searching for function to give output if value "is between" limits Hi excel novice, > searching for function to give output if value "is between" limits Use IF and AND like this; =IF(AND(value>=lowerLimit,value<=upperLimit),AnswerIfTrue,AnswerIfFalse) eg. This will output 100 if A1 is between 20 and 30, otherwise evaluates to zero =IF(AND(A1>=20,A1<=30),100,0) This will output 100 if A1 is between B1 and C1, otherwise evaluates to zero =IF(AND(A1>=B1,A1<=C1),100,0) Ed Ferrero www.edferrero.com ...

Converting bidirectional text files to and from ANSI
I need to convert bidirectional text files to and from ANSI format. Excel refers me to a "ConvText.exe" file that I do not have. Does anyone have this file or how can I get the file. Using excel 2002. I had never heard of Bidirectional text files, so I googled and found this: http://office.microsoft.com/en-us/assistance/HP052626761033.aspx Convert bidirectional text files to and from ANSI And the top of that web page started with: The ConvText utility is available on the installation CDs for Microsoft Office language versions that offer right-to-left support. So if you'...

user control of distro lists
I have set up some distro lists in AD. We have all 2003 servers and exchange 2003. I want to allow multiple users (if possible) to add and remove users to and from these lists. I saw a post already detailing this but I get no security tab on the dostro lists I created. I made the lists Universal and Distribution when I set them up. What do I need to do? Thanks. you need to view "advanced features" in your aduc console... -- Susan Conkey [MVP] "MikeB" <MikeB@discussions.microsoft.com> wrote in message news:2346AB31-9C7D-4761-8881-2D43475D68E5@microsoft....

gridlines print over text #2
When printing an Excel document with gridlines, some of them print over the text, and they don't line up properly. I've checked my text and spacing settings, and everything seems fine. Am I missing something? It sounds like the rows and/or columns are not big enough for the data - you could try the Autofit option Sheila "martikaih" wrote: > When printing an Excel document with gridlines, some of them print over the > text, and they don't line up properly. I've checked my text and spacing > settings, and everything seems fine. Am I missing something? ...

Formula in text boxes
I have heard you can put string arithmetic formula in text boxes. How do you do this? For example I would like to add the contents of three cells as follows: =B1&DOLLAR(B3,2)&B2 Thanks Will A text box can contain a cell reference -- Enter the formula in a cell on the worksheet Create a text box. Click on the text box to select it Click in the formula bar, and type an equal sign Click on the cell that contains the formula Press the Enter key Will Fleenor wrote: > I have heard you can put string arithmetic formula in text boxes. How do > you do this? For example I woul...