Exemplo n.º 1
0
        private void btnEditType_Click(object sender, EventArgs e)
        {
            if (dgwTypes.SelectedRows.Count > 0)
            {
                TypeForm tf = new TypeForm((Type)dgwTypes.SelectedRows[0].Tag);
                tf.ShowDialog();

                if (tf.DialogResult == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in dgwTypes.SelectedRows)
                    {
                        if (row.Selected)
                        {
                            Type t     = tf.GetResourceType();
                            int  index = dgwTypes.Rows.IndexOf(row);
                            dgwTypes.Rows.RemoveAt(index);
                            dgwTypes.Rows.Insert(index, new object[] { t.ID, t.Name });
                            dgwTypes.Rows[index].Tag = t;
                            dgwTypes.CurrentCell     = dgwTypes.Rows[index].Cells[0];
                            MainForm.types.Remove(t.ID);
                            MainForm.types.Add(t.ID, t);
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnNewType_Click(object sender, EventArgs e)
        {
            TypeForm tf;

            tf = new TypeForm();
            tf.ShowDialog();

            if (tf.DialogResult == DialogResult.OK)
            {
                Type t = tf.GetResourceType();
                MainForm.types.Add(t.ID, t);
                dgwTypes.Rows.Add(new object[] { t.ID, t.Name });
                dgwTypes.Rows[dgwTypes.Rows.Count - 1].Tag = t;
                dgwTypes.CurrentCell = dgwTypes.Rows[dgwTypes.Rows.Count - 1].Cells[0];
            }
        }