replace text with textbox...Need help!!!

I have a sentences of words which will contain this symbol '**'. How can i write the coding to replace the symbol with textbox Means, once the symbol '** is detected in the sentences, a textbox will be replaced...
Help is needed...thank you.....


Answer this question

replace text with textbox...Need help!!!

  • Vales

    I think this UI sucks, just for the record.

    Use the MeasureString method on the Graphics object to work out how far along your string the text box should be. Use the string.Split method to get substrings which you'll place between text boxes. Create text boxes manually and shove them into the controls collection to add them to the form. Make sure you set the tags with meaningful names so you can iterate over teh controls collection to find the values that were typed in and destroy the text boxes and also labels if you choose to use labels rather than render text in your paint method.

    Definatley a non trivial task.



  • excittor

    thank you for replying....
    my problem is.....i have a string which have the symbol ** inside the string....i want to display the string to a label and replace the symbol ** in the string to a textbox control which can let user to key in the data.....
    why i want to solve this problem is because once i get a string from a database ,the string will be displayed using a label, and the symbol ** in the string have to change to a textbox control to let user key in their data.....all the control will be created at runtime........
    hope u understand my problem and give me some hint to solve this...thank you....

  • Catherine Sea

    Hi,

    I think i got your point you could have a textbox which contains the sentences and ** where ** mean some one have to put here some text and now you want to give textbox interface for that and other text many be readonly.

    You problem can be simply resolved by following steps...

    Find and replace all strings of ** in text box and give then unique number e.g. [1],[2]


    Your string will look like this...

    Before
    Hi how are you Mr **. Your job id=** is confirm.

    After
    Hi how are you Mr [1]. Your job id=[2] is confirm.

    You can find by using textbox.text.indexof and replace by textbox.text.Replace

    Now add a panel under the text box and dynamically add labels and array of text boxex as you have already count for **
    e.g.

    Input text...
    enter text for [1] = [text box to get value]
    eneter text for [2] = [text box to get value]

    Then at the end you can loop through the textboxed get there value and finaly built your string.

    You can set and stander for unique pattern as i have used this [1]. you can use $$1 ##1 just to make sure that this pattern not exist in you string's readonly area.


    Hope this helps.



  • Rafayel

    thank you for your reply...i appreciate ur help...but i think my problem still unsolve, maybe you have misunderstand my question....
    my problem is eg.
    before : Your age is *****
    after : Your age is _____ <--textbox control
    i just want to replace ***** with a textbox......how can i find the position of the word where the *** appear and replace it by adding a textbox at tat position

    Thank you...please help.....
  • C. McGrunty

    This makes no sense to me. Do you want to put the word 'textbox' in there The replace method on the string will do that. But it sounds to me like you're rendering the string somewhere and want to put a textbox on the form. Is this right If so, why And how are you rendering the string In a label



  • SuperNova298

    I fear I am equally confused with the problem statement.



  • replace text with textbox...Need help!!!