예제 #1
0
        private DataRow GetDataRow(DataGridViewRow row, int defSelection)
        {
            DataRow dataRow = new DataRow();

            dataRow.Columns = new Dictionary <string, DataValue>();
            for (int i = 0, count = this._columns.Count; i < count; i++)
            {
                HSGridColumn column = this._columns[i];
                if (column.ColumnType == HSGridColumnType.None)
                {
                    continue;
                }

                DataValue dataValue = new DataValue();
                dataValue.Type = column.ValueType;
                if (column.ColumnType == HSGridColumnType.CheckBox)
                {
                    dataValue.Value = defSelection;
                }
                else
                {
                    dataValue.Value = row.Cells[i].Value;
                }
                dataRow.Columns[column.Name] = dataValue;
            }

            return(dataRow);
        }
예제 #2
0
        private void FillDataCell(ref DataGridViewRow row, HSGridColumn column, DataValue dataValue)
        {
            switch (column.ValueType)
            {
            case DataValueType.Int:
            {
                row.Cells[column.Name].Value = dataValue.GetInt();
            }
            break;

            case DataValueType.Float:
            {
                row.Cells[column.Name].Value = dataValue.GetDouble();
            }
            break;

            case DataValueType.Char:
            case DataValueType.String:
            {
                row.Cells[column.Name].Value = dataValue.GetStr();
            }
            break;

            default:
            {
                row.Cells[column.Name].Value = dataValue.GetStr();
            }
            break;
            }
        }
예제 #3
0
        private void AddColumns()
        {
            DataGridViewColumn[] gridColumns = new DataGridViewColumn[_columns.Count];
            for (int i = 0, count = _columns.Count; i < count; i++)
            {
                HSGridColumn col = _columns[i];

                DataGridViewColumn column = null;
                switch (col.ColumnType)
                {
                case HSGridColumnType.CheckBox:
                {
                    column = new DataGridViewCheckBoxColumn();
                }
                break;

                case HSGridColumnType.Image:
                {
                    column = new DataGridViewImageColumn();
                }
                break;

                case HSGridColumnType.Text:
                {
                    column = new DataGridViewTextBoxColumn();
                }
                break;

                default:
                {
                    column = new DataGridViewTextBoxColumn();
                }
                break;
                }

                column.HeaderText = col.Text;
                column.Name       = col.Name;
                column.Width      = col.Width;
                column.ReadOnly   = (col.ReadOnly != 0) ? true : false;
                gridColumns[i]    = column;
            }

            this.Columns.AddRange(gridColumns);
        }