Exemple #1
0
            protected override void OnClick(DataGridViewCellEventArgs e)
            {
                DataGridViewRow row      = this.OwningRow;
                DataGridView    view     = row.DataGridView;
                string          filename = row.Cells[2].Value as string;

                if (!string.IsNullOrEmpty(filename))
                {
                    Uri uri = new Uri(filename);
                    if (uri.IsFile)
                    {
                        var path = uri.LocalPath;
                        fd.InitialDirectory = System.IO.Path.GetDirectoryName(path);
                        fd.FileName         = System.IO.Path.GetFileName(path);
                    }
                }
                else
                {
                    fd.FileName = "";
                }
                fd.Multiselect = false;
                if (fd.ShowDialog(this.DataGridView.FindForm()) == DialogResult.OK)
                {
                    if (SchemaDialogCommand.ValidateSchema(row, fd.FileName) != null)
                    {
                        row.Cells[2].Value = fd.FileName;
                    }
                }
            }
Exemple #2
0
 void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (e.ColumnIndex == 2)
     {
         DataGridViewRow row      = this.dataGridView1.Rows[e.RowIndex];
         string          filename = e.FormattedValue as string;
         if (string.IsNullOrEmpty(filename))
         {
             return;
         }
         if (SchemaDialogCommand.ValidateSchema(row, filename) == null)
         {
             e.Cancel = true;
         }
     }
 }