Is there any way to disable some of the menu items of default textbox context menu?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kulabhishek
    New Member
    • Dec 2008
    • 26

    Is there any way to disable some of the menu items of default textbox context menu?

    I am developing windows application using C# 3.0 and .NET framework 3.5. My application has many forms and on them many text boxes and uses XML as back end.

    I am using Windows XP SP3 and have installed east Asian languages. After installing east Asian languages, i am getting three extra menu items in the default context menu (cut, copy, paste context menu) for text box. These three options are : "Right to left Reading order", "Show Unicode control characters" and "Insert Unicode control characters". The third option opens to right and displays Unicode control characters that can be added to text box (http://www.microsoft.com/resources/d....mspx?mfr=true).

    Last two options of these Unicode control characters are "Record Separator (Block separator)" and "Unit Separator (Segment separator)" which are invalid XML characters and so cannot be serialized to XML (I am using XMLSerializer).

    Now one way to handle this is to use validation, but I have many text boxes and some grid views so is there any other way to avoid these characters like disabling these two options or something like that?

    Regards,
    Abhishek
    Last edited by kulabhishek; Apr 28 '10, 04:52 PM. Reason: update
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well you could force your application to use a set language/locale, that *might* keep those items from happening.

    Comment

    • kulabhishek
      New Member
      • Dec 2008
      • 26

      #3
      Originally posted by Plater
      Well you could force your application to use a set language/locale, that *might* keep those items from happening.
      Thanks for your reply.

      Actually my application supports localization and it will be localized to some of the Asian languages, so cannot use a set language/locale.

      Regards
      Abhishek

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Then why would you want to get rid of the locale options in the context menu?

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          You could create your own context menu and assign it to your textbox. Give it just the options you want.

          Comment

          • kulabhishek
            New Member
            • Dec 2008
            • 26

            #6
            Originally posted by tlhintoq
            You could create your own context menu and assign it to your textbox. Give it just the options you want.
            Whenever i enter these two characters and try to serialize XML, it gives me exception.

            Yes creating my own context menu is one option, but i just wanted to know is there any other option.

            Thanks
            Abhishek

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Hmm, could you get away with searching through the entries and removing the bad characters?
              At some point you have to retreive the values from the input boxes right? Just do it there?

              Comment

              • kulabhishek
                New Member
                • Dec 2008
                • 26

                #8
                Originally posted by Plater
                Hmm, could you get away with searching through the entries and removing the bad characters?
                At some point you have to retreive the values from the input boxes right? Just do it there?
                Yes I can do that, but as I said there are many forms and text boxes in my application and all the code has already been written. So handling these characters while retrieving values is the last option for me to handle this.

                Thanks for your reply.
                Last edited by kulabhishek; Apr 30 '10, 06:27 PM. Reason: update

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  Well my point was SOMETHING already grabs the value.
                  Like: string myval=tbSomeInp ut.Text;
                  I would assume they are all gabbed at the same time? So add a function:
                  string myval= ParseStringFunc (tbSomeInput.Te xt);
                  Then write that function.

                  I understand wanting a better way, but in the time you've been looking for the answer, you could have long since had it all implemented

                  Comment

                  Working...