Exemple #1
0
        /// <summary>
        /// Pass data grid to go into edit mode
        /// </summary>
        /// <param name="tableInfo"></param>
        /// <param name="dataGrid"></param>
        public AddEditNewRowCustomTableDialog(TableInfo tableInfo, DataGridView dataGrid = null)
        {
            InitializeComponent();
            listOfControls = new List <CustomTableDialogControls>();
            this.tableInfo = tableInfo;
            foreach (ColumnInfo columnInfo in tableInfo.ColumnInfos_Row)
            {
                var tmp = new CustomTableDialogControls(mainPanel, columnInfo);
                if (columnInfo.ColumnType == ColumnType.Description)
                {
                    tmp.TxtInputValue.Multiline = true;
                }

                listOfControls.Add(tmp);
            }

            if (dataGrid != null)
            {
                if (dataGrid.SelectedRows.Count != 1)
                { // Potetnial troubleshooting goes here
                    return;
                }
                selectedRow   = dataGrid.SelectedRows[0];
                this.dataGrid = dataGrid;
                // - 2 becouse of index[0] and we have one additional hidden cell for table's Row ID
                // and our listOfControls cover only 'visible' cells
                for (int i = 0; i < selectedRow.Cells.Count - 2; i++)
                {   //out of range
                    if (listOfControls[i].Type == TypeCode.DateTime)
                    {
                        // +1 becouse first cell (column) is Ordinal Number,and we don't need that
                        listOfControls[i].TimePicker.Value = (DateTime)selectedRow.Cells[i + 1].Value;
                    }
                    else
                    {
                        listOfControls[i].TxtInputValue.Text = selectedRow.Cells[i + 1].Value.ToString();
                    }
                }
            }
        }
Exemple #2
0
 private void WriteErrorAndHighlightRow(CustomTableDialogControls dialogControls, string message)
 {
     lblError.Text    = message;
     lblError.Visible = true;
     dialogControls.ContainerPanel.BackColor = Color.Red;
 }