예제 #1
0
파일: Listview.cs 프로젝트: piwi1263/Tinkr
        public Listview(string name, Font headerFont, Font itemFont, int x, int y, int width, int height, string[] columns)
        {
            Name = name;
            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            X      = x;
            Y      = y;
            Width  = width;
            Height = height;
            // ReSharper restore DoNotCallOverridableMethodsInConstructor

            _header = headerFont;
            _item   = itemFont;

            if (columns != null)
            {
                _cols = new ListviewColumn[columns.Length];
                for (int i = 0; i < columns.Length; i++)
                {
                    _cols[i] = new ListviewColumn("column" + i, columns[i]);
                }
            }

            UpdateColumns();
            DefaultColors();
        }
예제 #2
0
파일: Listview.cs 프로젝트: piwi1263/Tinkr
        public void RemoveColumnAt(int index)
        {
            if (_cols == null || index < 0 || index >= _cols.Length)
            {
                return;
            }

            if (_cols.Length == 1)
            {
                _cols = null;
            }
            else
            {
                var tmp = new ListviewColumn[_cols.Length - 1];
                int c   = 0;
                for (int i = 0; i < _cols.Length; i++)
                {
                    if (i != index)
                    {
                        tmp[c++] = _cols[i];
                    }
                }
                _cols = tmp;
            }

            UpdateColumns();
            Invalidate();
        }
예제 #3
0
파일: Listview.cs 프로젝트: piwi1263/Tinkr
        public void RemoveColumn(ListviewColumn column)
        {
            if (_cols == null)
            {
                return;
            }

            for (int i = 0; i < _cols.Length; i++)
            {
                if (_cols[i] == column)
                {
                    RemoveColumnAt(i);
                    return;
                }
            }
        }
예제 #4
0
파일: Listview.cs 프로젝트: piwi1263/Tinkr
        public void AddColumn(ListviewColumn column)
        {
            if (_cols == null)
            {
                _cols = new[] { column };
            }
            else
            {
                var tmp = new ListviewColumn[_cols.Length + 1];
                Array.Copy(_cols, tmp, _cols.Length);
                tmp[tmp.Length - 1] = column;
                _cols = tmp;
            }

            UpdateColumns();
            Invalidate();
        }