Menu

How to replace existing MaskedTextBox?

Robert
2021-04-23
2021-04-23
  • Robert

    Robert - 2021-04-23

    I'd like to use your extended version instead of the original implementation in an already existing project, but I'm having trouble replacing the MaskedTextBox. I've copied the files in the /src folder to my project, but so far I wasn't successful in replacing the existing control with your version.
    I.e. I would like to keep all the formatting (location, size, etc) of the existing control and simply replace the type. So far I only encountered custom controls that directly extended the original one, and there I could just replace the "System.Windows.Forms.ControlName" with "CustomName.Space.CustomControlName", but yours seems to be a bit different, and I haven't really understood yet how to do this in this case.

     
  • Robert

    Robert - 2021-04-23

    Ok, for anyone reading this in the future, I needed to create a new class that inherits from the abstract class, and then call this new class from the Form and Form Designer.

    E.g. like this:

    using System;
    [...]
    using Opulos.Core.UI;
    
    namespace CustomControls {
        public partial class MyMaskedTextBox : MaskedTextBox<Object> {
            public override Object TextToValue(String text) {
                return default(Object);
            }
    
            public override String ValueToText(Object value) {
                return null;
            }
    
            public MyMaskedTextBox() {
                [...]
            }
        }
    }
    

    This way it also shows up in the designer.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.