Enabled property

Discussion in 'ASP .Net' started by Paul Hendrickson, Aug 17, 2003.

  1. I am writing a word processor using a rich text box. I want to disable
    (Grey out) some things on the mainmenu like 'Cut' or 'Copy' when there is no
    text selected. Here is what I thought would work:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    MenuItemCut.Enabled = False
    End Sub
    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
    If RichTextBox1.SelectedText <> "" Then
    MenuItemCut.Enabled = True
    Else
    MenuItemCut.Enabled = False
    End If
    End Sub


    If I changed the 'If' line to:

    If RichTextBox1.Text <> "" Then

    It disables cut until I load a file. I want cut to be disabled until I
    select something. What am I doing wrong here?
    I've tried different combinations like setting the cut enabled property to
    true or false, etc.

    Thanks in advance!

    Paul Hendrickson
     
    Paul Hendrickson, Aug 17, 2003
    #1
    1. Advertising

  2. Paul Hendrickson

    Arpi Tot Guest

    Try to use the

    SelectionChanged event instead of the TextChanged event.

    "Paul Hendrickson" <> wrote in message
    news:...
    > I am writing a word processor using a rich text box. I want to disable
    > (Grey out) some things on the mainmenu like 'Cut' or 'Copy' when there is

    no
    > text selected. Here is what I thought would work:
    >
    > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > MenuItemCut.Enabled = False
    > End Sub
    > Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object,
    > ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
    > If RichTextBox1.SelectedText <> "" Then
    > MenuItemCut.Enabled = True
    > Else
    > MenuItemCut.Enabled = False
    > End If
    > End Sub
    >
    >
    > If I changed the 'If' line to:
    >
    > If RichTextBox1.Text <> "" Then
    >
    > It disables cut until I load a file. I want cut to be disabled until I
    > select something. What am I doing wrong here?
    > I've tried different combinations like setting the cut enabled property to
    > true or false, etc.
    >
    > Thanks in advance!
    >
    > Paul Hendrickson
    >
    >
    >
     
    Arpi Tot, Aug 19, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gabor
    Replies:
    3
    Views:
    660
    Jacob Yang [MSFT]
    Aug 26, 2003
  2. Rick Shide

    Button.Enabled property not being set

    Rick Shide, Sep 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    639
    Rick Shide
    Sep 11, 2003
  3. Cipher
    Replies:
    3
    Views:
    1,540
    coollzh
    Apr 30, 2004
  4. Rob

    Enabled property

    Rob, Apr 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    402
  5. Gill Smith
    Replies:
    4
    Views:
    8,916
    Gish Smith
    May 22, 2004
Loading...

Share This Page