Skip to content

Auto create WinForm for class with attributes «FormControlAttribute»

License

Notifications You must be signed in to change notification settings

EugenePuntus/AutoGenerateWinForms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoGenerateWinForms

Auto create WinForm for class with attributes «FormControlAttribute»

How to use

    class Program
    {
        static void Main(string[] args)
        {
            var winFormGenerated = new WinFormGenerating();
            var exemplar = new ExampleFormGenerating()
            {
                MyBool = true,
                MyNumber = 10,
                MyNumber2 = 99.20m,
                MyString = "Тестовая строка"
            };

            var form = winFormGenerated.GetForm(exemplar);
            form.ShowDialog();

            Console.WriteLine(exemplar.Result);
        }
    }

    public class ExampleFormGenerating
    {
        [FormControl(Type = FormControlType.TextBox, LabelText = "Number Int")]
        public int MyNumber { get; set; }

        [FormControl(Type = FormControlType.TextBox, LabelText = "Number Decimal")]
        public decimal MyNumber2 { get; set; }

        [FormControl(Type = FormControlType.TextBox, LabelText = "String")]
        public string MyString { get; set; }

        [FormControl(Type = FormControlType.ComboBox, LabelText = "Bool", DataSourse = new[] {true,false})]
        public bool MyBool { get; set; }

        public string Result => $"{MyNumber} | {MyNumber2} | {MyString} | {MyBool}";
    }

The generated form and result in the console

alt text

alt text

About

Auto create WinForm for class with attributes «FormControlAttribute»

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages