Пример #1
0
        /// <summary>
        /// The <see cref="DataGridView.ColumnHeaderMouseClick"/> event handler for
        /// the <see cref="DataGridView"/> <see cref="dGVPreviewImport"/>.
        /// Column header clicked. Used for changing column header text with dialog.
        /// If the user clicked on the column header a <see cref="AskForColumTitleDialog"/>
        /// dialog is shown and the <see cref="ASCIISettings.ColumnHeaders"/>
        /// is updated.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">An empty <see cref="EventArgs"/></param>
        private void dGVPreviewImport_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            AskForColumTitleDialog dlg = new AskForColumTitleDialog();
            string oldHeader           = this.dGVPreviewImport.Columns[e.ColumnIndex].HeaderText;

            dlg.ColumnTitle = oldHeader;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                this.dGVPreviewImport.Columns[e.ColumnIndex].HeaderText = dlg.ColumnTitle;
            }

            // Rewrite column headers dictionary.
            this.asciiSetting.ColumnHeaders.Clear();
            for (int i = 0; i < this.dGVPreviewImport.Columns.Count; i++)
            {
                this.asciiSetting.ColumnHeaders.Add(this.dGVPreviewImport.Columns[i].HeaderText);
            }

            // Update columnassignments if applicable
            string key = string.Empty;

            if (this.asciiSetting.ColumnAssignments.ContainsValue(oldHeader))
            {
                foreach (KeyValuePair <string, string> kvp in this.asciiSetting.ColumnAssignments)
                {
                    if (kvp.Value == oldHeader)
                    {
                        key = kvp.Key;
                    }
                }

                this.asciiSetting.ColumnAssignments[key] = dlg.ColumnTitle;
            }

            this.UpdatePreview(false);
        }
Пример #2
0
    /// <summary>
    /// The <see cref="DataGridView.ColumnHeaderMouseClick"/> event handler for
    /// the <see cref="DataGridView"/> <see cref="dGVPreviewImport"/>.
    /// Column header clicked. Used for changing column header text with dialog.
    /// If the user clicked on the column header a <see cref="AskForColumTitleDialog"/>
    /// dialog is shown and the <see cref="ASCIISettings.ColumnHeaders"/>
    /// is updated.
    /// </summary>
    /// <param name="sender">Source of the event.</param>
    /// <param name="e">An empty <see cref="EventArgs"/></param>
    private void dGVPreviewImport_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
      AskForColumTitleDialog dlg = new AskForColumTitleDialog();
      string oldHeader = this.dGVPreviewImport.Columns[e.ColumnIndex].HeaderText;
      dlg.ColumnTitle = oldHeader;
      if (dlg.ShowDialog() == DialogResult.OK)
      {
        this.dGVPreviewImport.Columns[e.ColumnIndex].HeaderText = dlg.ColumnTitle;
      }

      // Rewrite column headers dictionary.
      this.asciiSetting.ColumnHeaders.Clear();
      for (int i = 0; i < this.dGVPreviewImport.Columns.Count; i++)
      {
        this.asciiSetting.ColumnHeaders.Add(this.dGVPreviewImport.Columns[i].HeaderText);
      }

      // Update columnassignments if applicable
      string key = string.Empty;
      if (this.asciiSetting.ColumnAssignments.ContainsValue(oldHeader))
      {
        foreach (KeyValuePair<string, string> kvp in this.asciiSetting.ColumnAssignments)
        {
          if (kvp.Value == oldHeader)
          {
            key = kvp.Key;
          }
        }

        this.asciiSetting.ColumnAssignments[key] = dlg.ColumnTitle;
      }

      this.UpdatePreview(false);
    }