RichEditText box not enabled=false on runtime

In this category you can exchange your programming questions and solutions.
Post Reply
Darren
Posts: 63
Joined: Wed May 11, 2011 11:55 am

RichEditText box not enabled=false on runtime

Post: # 1194Post Darren
Fri Jun 27, 2014 6:28 pm

Can anybody help?

I have two RichEdit boxes, 1 and 2

RichEdit2.Enabled =false!!!!

On run RichEdit2 is not shown disabled (eg Greyed out)

Run the source code and delete the text from RichEdit1 then you will see RichEdit2 is Greyed out. Why does it not get Greyed out when I run the code from the start?

Thanks in advance!!!

HERE IS THE CODE

OBJECT NewForm AS Form
  Left=247
  Top=119
  Caption="New Form"
  ClientHeight=121
  ClientWidth=384
  OBJECT Button1 AS Button
    Left=304
    Top=88
    Width=75
    Height=25
    Caption="OK"
    TabOrder=0
    OnClick=Button1_Click
  END OBJECT `{Button1}
  OBJECT RichEdit1 AS RichEdit
    Left=16
    Top=8
    Width=361
    Height=30
    Text="REMOVE THIS TEXT AND RICHEDIT2 WILL BE GREYED OUT BUT NOT ON RUN!!"
    TabOrder=1
    OnKeyPress=RichEdit1_KeyPress
    OnChange=CheckInput
  END OBJECT `{RichEdit1}
  OBJECT RichEdit2 AS RichEdit
    Left=16
    Top=48
    Width=361
    Height=25
    Text=""
    Enabled=False
    TabOrder=2
  END OBJECT `{RichEdit2}
END OBJECT `{NewForm}

NewForm.ShowModal

Sub Button1_Click()
    End
End Sub

Sub RichEdit1_KeyPress(Key as byte)
    If Key < 48 Then
       Select Case Key
         Case 8, 32, 45
         Case Else
              Key = 0
       End Select
    End If

    If Key > 57 And Key < 65 Then Key = 0

    If Key > 90 And Key < 97 Then Key = 0

    If Key > 122 Then Key = 0
End Sub

Sub CheckInput()
    If RichEdit1.Text="" Then
       RichEdit2.Enabled = False
    Else
       RichEdit2.Enabled = True
    End If
End Sub

Marco
Site Admin
Posts: 246
Joined: Sat Sep 15, 2018 8:41 pm

RichEditText box not enabled=false on runtime

Post: # 1195Post Marco
Tue Jul 01, 2014 3:32 pm

Could be a bug at my side or a windows bug.

Here is a work around:

OBJECT NewForm AS Form
  Left=247
  Top=119
  Caption="New Form"
  ClientHeight=121
  ClientWidth=384
  onshow=disableredit `this added could be onpaint as well
  OBJECT Button1 AS Button
    Left=304
    Top=88
    Width=75
    Height=25
    Caption="OK"
    TabOrder=0
    OnClick=Button1_Click
  END OBJECT `{Button1}
  OBJECT RichEdit1 AS RichEdit
    Left=8
    Top=8
    Width=375
    Height=30
    Text="REMOVE THIS TEXT AND RICHEDIT2 WILL BE GREYED OUT BUT NOT ON RUN!!"
    TabOrder=1
    OnKeyPress=RichEdit1_KeyPress
    OnChange=CheckInput
  END OBJECT `{RichEdit1}
  OBJECT RichEdit2 AS RichEdit
    Left=8
    Top=48
    Width=375
    Height=25
    Text=""
    Enabled=False
    TabOrder=2
  END OBJECT `{RichEdit2}
END OBJECT `{NewForm}

NewForm.ShowModal

`event added to disable richedit
sub disableredit
  RichEdit2.enabled=true
  RichEdit2.enabled=false
end sub
`=====end event=================

Sub Button1_Click()
    End
End Sub

Sub RichEdit1_KeyPress(Key as byte)
    If Key < 48 Then
       Select Case Key
         Case 8, 32, 45
         Case Else
              Key = 0
       End Select
    End If

    If Key > 57 And Key < 65 Then Key = 0

    If Key > 90 And Key < 97 Then Key = 0

    If Key > 122 Then Key = 0
End Sub

Sub CheckInput()
    If RichEdit1.Text="" Then
       RichEdit2.Enabled = False
    Else
       RichEdit2.Enabled = True
    End If
End Sub

Post Reply