예제 #1
0
        private void TsbtnAddTemplates_Click(object sender, EventArgs e)
        {
            OfdAddTemplates.InitialDirectory = TxtDirectoryPath.Text;
            OfdAddTemplates.Filter           = "Office Files (*.xlsx; *.docx)|*.xlsx; *.docx";

            DialogResult result = OfdAddTemplates.ShowDialog();

            if (result == DialogResult.OK)
            {
                var files = OfdAddTemplates.FileNames;

                for (int i = 0; i < files.Length; i++)
                {
                    try
                    {
                        BsDocumentTemplateObject = _bindingSourceService.AddNewTemplateToBindingSourceFromFile(DgvDocumentTemplates, BsDocumentTemplateObject, files[i]);
                    }
                    catch (DuplicateException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }

            DgvDocumentTemplates.ClearSelection();
        }
예제 #2
0
        private void DgvDocumentTemplate_MouseDown(object sender, MouseEventArgs e)
        {
            var ht = DgvDocumentTemplates.HitTest(e.X, e.Y);

            if (ht.Type == DataGridViewHitTestType.None)
            {
                DgvDocumentTemplates.ClearSelection();
            }
        }
예제 #3
0
        private void DgvDocumentTemplate_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                for (int i = 0; i < files.Length; i++)
                {
                    try
                    {
                        BsDocumentTemplateObject = _bindingSourceService.AddNewTemplateToBindingSourceFromFile(DgvDocumentTemplates, BsDocumentTemplateObject, files[i]);
                    }
                    catch (DuplicateException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                DgvDocumentTemplates.ClearSelection();
            }
        }