Results 1 to 5 of 5

Thread: Non-editable edit control?

  1. #1

    Non-editable edit control?

    Is there any way to make a control that looks like a TEdit (one-line textbox) on screen, but can only display data, not receive keyboard focus? Setting the ReadOnly property isn't enough; that still allows you to select the text. What I'm looking for is basically a label that looks exactly like a TEdit.

    (The reason for this is that the edit box displays modifiable data that can be edited, but only by changing a value elsewhere; editing it directly would cause problems, and allowing it to receive focus while not being editable would cause confusion. Better to just make it non-editable, but still look like a TEdit to make its nature as a box that holds modifiable data clear.)

    Mason

  2. #2
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,231
    Blog Entries
    2

    Non-editable edit control?

    You have three relatively easy options (that I can think of now).

    a) Use a TEdit, set the readonly property to true and the enabled property to false. The text is greyed, but the control cannot receive focus.

    b) Use a TStaticText. It can be configured to have a border and the background colour can be changed. It looks similar to TEdit but not exactly like it.

    c) Use a combination of a TPanel (to give the border style and background colour) and a TLabel. Nasty, but it would probably end up looking like an enabled TEdit the most.

    They are the three easy options I can think of off the top of my head.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #3

    Non-editable edit control?

    An easier option is to put a TEdit on a TPanel and then set the enabled property of the TPanel to false.

    Now you cannot select the TEdit but it still looks correct - white with black text.

    Set the panel's bevelinner and bevelouter to bvnone
    The views expressed on this programme are bloody good ones. - Fred Dagg

  4. #4

    Non-editable edit control?

    Hey masonwheeler,

    How did you get on? There has been no reply.
    The views expressed on this programme are bloody good ones. - Fred Dagg

  5. #5

    Non-editable edit control?

    I've been on here regularly, watching. I just haven't replied to this thread yet.

    Mason

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL