Search code examples
bunifu

How to set max length for "Bunifu .NET UI Framework" text box?


I have developed a windows form application using Bunifu .NET UI Framework.

But I have a problem, I want to set max length of the text box.

Therefore please give me some advice, how can I do it?


Solution

  • You can likewise use the method below:

    /// <summary>
    /// Sets the maximum length of text in Bunifu MetroTextBox.
    /// </summary>
    /// <param name="metroTextbox">The Bunifu MetroTextbox control.</param>
    /// <param name="maximumLength">The maximum length of text to edit.</param>
    private void SetMaximumLength(Bunifu.Framework.UI.BunifuMetroTextbox metroTextbox, int maximumLength)
    {
        foreach (Control ctl in metroTextbox.Controls)
        {
            if (ctl.GetType() == typeof(TextBox))
            {
                var txt = (TextBox)ctl;
                txt.MaxLength = maximumLength;
    
                // Set other properties & events here...
            }
        }
    }