CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2001
    Location
    germany
    Posts
    772

    ComboBox Text Property

    Hi,

    I am having a ComboBox called targetCombo. The first item which shows up is set with

    targetCombo.text = "jhg"

    The problem is that when I want to change it I get the Error that the Text Property is read only.
    How can I change the first choice in the combo box?

    One more question:

    Depending on a selection in the combo box I want a radio button to enable or disable. How can I make the comboBox selection take action on the radio button?


    Please rate if it helps!

    * The second mouse gets the cheese.

    * Birthdays are good for you. The more you have, the longer you live.

    * Always keep your words soft and sweet, just in case you have to eat them.

    * Always read stuff that will make you look good if you die in the middle of it.

  2. #2
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: ComboBox Text Property

    you have to select the item thru the List property.


    combo1.list(1) = "Blah"




    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  3. #3
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: ComboBox Text Property

    You can use combobox.value = "Your text here"

    Nicolas Bohemier

  4. #4
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: ComboBox Text Property

    If your ComboBox style property is set to DropDropDown List (2) then it is indeed a Readonly box. Set the style to 0 or 1 to be able to enter data into it programattically. To prevent users from keying data when style is 0 or 1, add this to the KeyPress event of the comboBox

    private Sub Combo1_KeyPress(KeyAscii as Integer)
    KeyAscii = 0
    End Sub




    John G

  5. #5
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: ComboBox Text Property


    option Explicit

    private Sub Combo1_Change()
    If Combo1.Text = "Item1 - RadioButton Enabled" then
    Option1.Enabled = true
    else
    Option1.Enabled = false
    End If
    End Sub

    private Sub Combo1_Click()
    Combo1_Change
    End Sub

    private Sub Form_Load()
    Combo1.AddItem "Item1 - RadioButton Enabled"
    Combo1.AddItem "Item2 - RadioButton Disabled"

    Combo1.Text = "Item1 - RadioButton Enabled"
    End Sub





Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured