Git Product home page Git Product logo

autosizememo's Introduction

DxUltimate Sample: AutoSizeMemoEdit - An Auto-Sizing DevExpress MemoEdit Control

1. Introduction

DevExpress WinForms controls employ multiple different mechanism for automatic sizing of controls. I'll just name the three that are relevant in this case:

  1. WinForms.Control.AutoSize
    The normal auto-sizing mechanism provided by the WinForms framework
  2. DevExpress.XtraEditors.BaseControl.AutoSizeInLayoutControl
    A DX specific mechanism for autosizing controls inside a LayoutControl
  3. DevExpress.XtraEditors.Controls.IAutoHeightControl
    Another DC specific mechanism which is focusing on automatic height. Its primary purpose seems to be autosizing editors inside grid and list controls to allow variable row heights

The MemoEdit control implements #3, but not #1 and #2. I'm not sure about the reason, but I suspect that the intention might have been to avoid confusion with AutoSize (#1) when the MemoEdit is used in DataGrid & Co.

2. The Problem

Is simple: You cannot use the MemoEdit in a form/control and neither in a LayoutControl and let it autosize by its contents, because #1 and #2 are not implemented.

3. Solution

This example includes an inherited MemoEdit control: AutoSizeMemoEdit

The AutoSizeMemoEdit control implements both missing autosizing mechanisms (#1 and #2), and nothing else is required than placing it on a form or control or on a LayoutControl.

Usage

There are three different use cases, each of which is controlled by a different setting:

  • Standalone Edit Control
    set AutoSizeMemoEdit.AutoSize
  • Inside regular XtraLayoutControl (and DataLayoutControl)
    set AutoSizeMemoEdit.AutoSizeInLayoutControl
  • In a LayoutView inside xtraGrid
    set RepositoryItemAutoSizeMemoEdit.AutoSizeInGridLayoutView

Important Note

This control is made specifically for the demonstrated use cases. It might or might not work in other situations.

4. Examples

In LayoutControl

Scrollbars are set to False by default and AutoSizeInLayoutControl is set to True:

Auto Size Memo 1

In AutoSize-Form

The AutoSize property of the AutoSizeMemoEdit is set to True and AutoSizeMode to GrowOrShrink. Finally, AutoSize of the Form is set to True as well, resulting in the complete form resizing when editing:

Auto Size Memo 2

In Form with Dock Panels

In this case, the form is not set to AutoSize and the AutoSizeMemoEdit control is automatically resizing itself to show all of its contents:

Auto Size Memo 3

In a LayoutView inside the DataGrid Control

This requires setting the AutoSizeInGridLayoutView of the RepositoryItemAutoSizeMemoEdit after adding AutoSizeMemoEdit as a ColumnEdit in the LayoutView.

Auto Size Memo 4

autosizememo's People

Contributors

matthiasmoetje avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.