private void loadList(DataGrid dgList, DataTable dtList, Color backColor)
        {
            try
            {
                dgList.TableStyles.Clear();
                dgList.DataSource = dtList;
                DataGridTableStyle tableStyle = new DataGridTableStyle();
                tableStyle.MappingName = dtList.TableName;

                foreach (DataColumn item in dtList.Columns)
                {
                    switch (item.ColumnName)
                    {
                    case COL_TRANSFER:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn(backColor, Color.Black);
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "Transfer number";
                        tbcName.Width       = 143;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    case COL_ACTION:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "Action";
                        tbcName.Width       = 50;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    default:
                    {
                        //DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        //tbcName.Width = 20;
                        //tableStyle.GridColumnStyles.Add(tbcName);
                    } break;
                    }
                }

                dgList.TableStyles.Add(tableStyle);
                dgList.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
        private void loadList(DataGrid dgList, DataTable dtList, Color backColor)
        {
            try
            {
                dgList.TableStyles.Clear();
                dgList.DataSource = dtList;
                DataGridTableStyle tableStyle = new DataGridTableStyle();
                tableStyle.MappingName = dtList.TableName;

                foreach (DataColumn item in dtList.Columns)
                {
                    switch (item.ColumnName)
                    {
                    case COL_INTERNAL_REFERENCE:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "Product";
                        tbcName.Width       = 90;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    case COL_MAN_PN:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "ManPN";
                        tbcName.Width       = 70;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    case COL_INITIAL_QUANTITY:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "Initial";
                        tbcName.Width       = 40;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    case COL_DONE_QUANTITY:
                    {
                        DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        tbcName.MappingName = item.ColumnName;
                        tbcName.HeaderText  = "Done";
                        tbcName.Width       = 40;
                        tbcName.Format      = "{0:0000}";
                        tableStyle.GridColumnStyles.Add(tbcName);
                    } break;

                    default:
                    {
                        //DataGridExtendedTextBoxColumn tbcName = new DataGridExtendedTextBoxColumn();
                        //tbcName.Width = 20;
                        //tableStyle.GridColumnStyles.Add(tbcName);
                    } break;
                    }
                }

                dgList.TableStyles.Add(tableStyle);
                dgList.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }