Česky
Kamil Dudka

Tiny programs (C, C++, C#, ...)

File detail

Name:DownloadCategoryEditor.cs [Download]
Location: tiny > MW5 > proj2 > proj2 > UserControls
Size:2.0 KB
Last modification:2007-08-29 17:43

Source code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace proj2.UserControls
{
    public partial class CategoryEditor : Form
    {
        public event EventHandler ValidatingId;
        public CategoryEditor()
        {
            InitializeComponent();
            id.Maximum = decimal.MaxValue;
        }
        public int CategoryId
        {
            get { return (int)id.Value; }
            set { id.Value = value; }
        }
        public bool CategoryIdEnabled
        {
            get { return id.Enabled; }
            set { id.Enabled = value; }
        }
        public bool CategoryIdVisibility
        {
            get { return id.Visible; }
            set { idLabel.Visible = id.Visible = value; }
        }
        public string CategoryName
        {
            get { return name.Text; }
            set { name.Text = value; }
        }
        public int CategoryNameMaxLength
        {
            get { return name.MaxLength; }
            set { name.MaxLength = value; }
        }
        public string CategoryDescription
        {
            get { return description.Text; }
            set { description.Text = value; }
        }
        public int CategoryDescriptionMaxLength
        {
            get { return description.MaxLength; }
            set { description.MaxLength = value; }
        }
 
        private void id_Validating(object sender, CancelEventArgs e)
        {
            if (ValidatingId != null)
                ValidatingId(this, e);
            Control idControl = (Control)sender;
            String strError = string.Empty;
            if (e.Cancel)
                strError = "Invalid ID";
            errorProvider1.SetError(idControl, strError);
        }
 
        private void CategoryEditor_Load(object sender, EventArgs e)
        {
            ActiveControl = name;
            name.SelectAll();
        }
    }
}