Skip to content

Cell edit mode (double-click / Ctrl+E) ignores configured font – RowsDefaultCellStyle hardcodes Courier New #720

Description

@JuliusSMF

Description

When a cell in the log view (or the filter view) enters edit mode – via double-click or Ctrl+E, e.g. to select and copy part of a line – the text switches from the configured font to Courier New 8.25pt. After leaving edit mode the configured font is shown again.

This is point 2 of #565, which is still reproducible on current Development (1637c2b). PR #579 (#573) fixed font handling in general but did not touch this code path.

Steps to reproduce

  1. Settings → choose any font other than Courier New (e.g. Consolas 10pt)
  2. Open a log file
  3. Double-click a line (or press Ctrl+E)

Expected: the edit control uses the configured font
Actual: the edit control uses Courier New 8.25pt

Root cause

  • The grid content is painted manually (PaintHighlightedCell → TextRenderer.DrawText) using NormalFont, so the display is correct.
  • The editing control (LogCellEditingControl) is not painted manually; it takes its font from the inherited cell style.
  • LogWindow.PreferencesChanged only sets dataGridView.DefaultCellStyle.Font / filterGridView.DefaultCellStyle.Font.
  • LogWindow.CreateDefaultViewStyle assigns RowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(darkMode), which hardcodes new Font("Courier New", 8.25F, ...).
  • In the DataGridView style inheritance, RowsDefaultCellStyle takes precedence over DefaultCellStyle, so the editing control always ends up with Courier New 8.25pt.

Proposed fix

Keep RowsDefaultCellStyle.Font in sync with the configured font in LogWindow.PreferencesChanged:

dataGridView.DefaultCellStyle.Font = NormalFont;
filterGridView.DefaultCellStyle.Font = NormalFont;
// RowsDefaultCellStyle has precedence over DefaultCellStyle; the cell editing control
// (double-click / Ctrl+E) inherits its font from there, so keep both in sync.
dataGridView.RowsDefaultCellStyle.Font = NormalFont;
filterGridView.RowsDefaultCellStyle.Font = NormalFont;

Tested locally: the edit control now uses the configured font in both the log view and the filter view, also after changing the font in the settings at runtime.

Alternatively (or additionally), the hardcoded Font could be removed from PaintHelper.GetDataGridDefaultRowStyle so the row style inherits from DefaultCellStyle (see also the existing TODO there referencing #85).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugPesky little gritter, needs squashingenhancementthis will make things better

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions