Freeze table rows

Post Reply
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Freeze table rows

Post by Natter »

Hi,

Is it possible to fix (freeze) table rows in RichEdit ?
User avatar
Antonio Linares
Site Admin
Posts: 42831
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 155 times
Been thanked: 119 times
Contact:

Re: Freeze table rows

Post by Antonio Linares »

In RichEdit, a Windows control for rich text editing, there is no built-in feature to "freeze" table rows like in spreadsheet applications (e.g., Excel). RichEdit supports basic table functionality through Rich Text Format (RTF) specifications, but it lacks advanced table management capabilities such as freezing rows for scrolling purposes.

However, you can achieve a similar effect programmatically or through workarounds, depending on your application’s requirements.

Here are some approaches:

Custom Implementation in Your Application:
If you’re using RichEdit in a custom application (e.g., with C++, Delphi, or C#), you can simulate frozen rows by splitting the content into two RichEdit controls:

One control displays the "frozen" header rows (non-scrollable).
Another control below it contains the scrollable table content.
Synchronize the column widths and formatting between the two controls to maintain alignment.
Handle scrolling events to keep the header control static while the body scrolls.

RTF Table Formatting:

RichEdit’s RTF tables (using \trowd and related RTF codes) allow basic table creation but don’t support freezing rows natively.
You can manually ensure that header rows remain visible by programmatically keeping them at the top of the visible area when scrolling. This requires handling scroll events and adjusting the view, which can be complex and may not be seamless.

Alternative Controls:

If freezing table rows is a critical feature, consider using a more advanced control like a grid control (e.g., TGrid in Delphi, DataGridView in .NET, or third-party controls like DevExpress or Telerik) instead of RichEdit. These controls are designed for tabular data and often support frozen rows/columns natively.

Limitations:

RichEdit is primarily a text-editing control, not a spreadsheet or grid control. Its table support is limited to basic formatting and lacks advanced features like row/column locking.

Implementing a freeze-like feature in RichEdit requires significant custom code and may not provide a smooth user experience.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Freeze table rows

Post by Natter »

Thank you, Antonio! I understood
Post Reply