How do I change the selected text of a combobox on the fly?

Hi all,
I am trying to make a combobox, that is sort of a "recently used" connection box. So you can type in a computer name, hit connect and it then connects. When you disconnect, it adds the computer name, and the logged in username to the combobox,
so when you click on the drop down, you get selections for example : "COMPUTER1 - johnsmith"
Which is cool, but what I want, is to be able to click on the selection, and it only puts the computer name in the TextBox - i.e. "COMPUTER1"
So I have done a bit of research, and tried making a hashtable, and using the DisplayMember and ValueMember properties, so i can at least have a combobox selection like "COMPUTER1 (johnsmith)". I have tried many different pages and suggestions,
but the furtherest I have got is to only have one or the other value display, or it displays as System.Collection...... (can't remember the rest).
So my next attempt, is using an event handler for the combobox to change the text, so that once "COMPUTER1 - johnsmith" is selected from the combobox, it puts "COMPUTER1" as the selected text.
I have tried the following using the SelectedIndexChanged handler. Here is a snippet of my code relating to the ComboBox:
# PC Connection Input Box$global:pcInputBox = New-Object System.Windows.Forms.ComboBox
$global:pcInputBox.Location = New-Object System.Drawing.Size(70,50)
$global:pcInputBox.Size = New-Object System.Drawing.Size(210,20)
$global:pcInputBox_SelectedIndexChanged = {
if (($global:pcInputBox.Text -ne $null) -and ($global:pcInputBox.Text -ne "")){
$selection = $global:pcInputBox.Text
addLog("Selection is $selection")
$global:trimSelection = $selection.substring(0,$selection.indexof("-"))
addLog("TrimSelection is $global:trimSelection")
$global:pcInputBox.SelectedItem = $global:trimSelection
addLog("SelectedText is $global:pcInputBox.SelectedItem")
$global:pcInputBox.add_GotFocus({
$Form.AcceptButton = $pcButton
$global:pcInputBox.add_SelectedIndexChanged($global:pcInputBox_SelectedIndexChanged)
$Form.Controls.Add($global:pcInputBox)
I have also tried setting the $global:pcInputBox.Text but the result is that nothing changes. Its as though I can't change that ComboBox from its own event?? If I try setting $global:pcInputBox.Text from another function, it will do it fine.
Can anyone please recommend how I would get this achieved?
Thanks in advance
Adam Street

Use objects:
$o=@()
$o+=New-Object PsObject -Property @{Computer='COMP1';User='USER01'}
$o+=New-Object PsObject -Property @{Computer='COMP2';User='USER02'}
$o+=New-Object PsObject -Property @{Computer='COMP3';User='USER03'}
$combobox1.DataSource=[collections.arraylist]($o|select Computer,User, @{N='DisplayName';E={"$($_.Computer)-$($_.User)"}})
$combobox1.DisplayMember='DisplayName'
This can also be loaded from a CSV or from AD or almost anywhere else;
Here is another trivial example:
$o=@()
$o+=New-Object PsObject -Property @{Computer='COMP1';User='USER01'}
$o+=New-Object PsObject -Property @{Computer='COMP2';User='USER02'}
$o+=New-Object PsObject -Property @{Computer='COMP3';User='USER03'}
Add-Type -AssemblyName System.Windows.Forms
$form=New-Object System.Windows.Forms.Form
$form.StartPosition='CenterScreen'
$combobox1 = New-Object System.Windows.Forms.ComboBox
$combobox1.Location='70,50'
$combobox1.Size='210,20'
$combobox1.DataSource=[collections.arraylist]($o|select Computer,User, @{N='DisplayName';E={"$($_.Computer)-$($_.User)"}})
$combobox1.DisplayMember='DisplayName'
$combobox1.add_SelectedIndexChanged({[System.Windows.Forms.MessageBox]::Show($combobox1.SelectedItem.Computer)})
$form.Controls.Add($combobox1)
$form.ShowDialog()
¯\_(ツ)_/¯

Similar Messages

  • How can i Change the Size of the selected text in JTextPane using ConboBox

    plzz help...
    How can i Change the Size of the selected text in JTextPane using ConboBox ???
    i m using if(cb.getSelectedItem=="small")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 12);)
    if(cb.getSelectedItem=="medium")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 14);)
    if(cb.getSelectedItem=="large")
    cb.setAction(new StyledEditorKit.FontSizeAction("double click", 16);)
    this code is not working properly according to the action i set on comboBox.
    when i select medium the previously set action on comboBox works like small action work.
    when i select large the medium action starts .
    means its not working in correct time when i select item of combox n action of that item is not working at that time..
    plzz plzz help me:(

    Action action1 = new StyledEditorKit.FontSizeAction(
    "double click", 12);
    Action action2 = new StyledEditorKit.FontSizeAction(
    "double click", 14);
    Action action3 = new StyledEditorKit.FontSizeAction(
    "double click", 18);
    s2 = (String) cb7.getSelectedItem();
    if (s2.equals("Small")) {
    cb7.setAction(action1);
    e1.setSource(cb7);
    } else
    if (s2.equals("Medium")) {
    cb7.setAction(action2);
    e1.setSource(cb7);
    } else if (s2.equals("Large")) {
    cb7.setAction(action3);
    // e1.setSource(cb7);
    when i chooze any combobox item then according to that item i set the Action on ComboBox but that action is not working properly on the selected text in the JTextPane..means selected text in JText Pane is not changes its Size according to the comboBox selected ITEM.
    PLZ plzzzzzzzzzz help me:((.i will be thankfull to u.

  • How can i change the color of the text on a button in Roll Over or Click state (Cs5.5)

    Hello,
    Here is the problematic:
    1° How can i change the color of the text on a button in Roll Over or Click state (Cs5.5)
    - I've many button in a doc im creating
    - the color of the buttons is white with black stoke & black text
    - in roll over state i want them to inverse the color coding (the text white & bottom black)
    - currently the text becomes invisible as black on black cant be seen (ive stroked it white but that looks ugly)
    - i would just like to know if there is a function made for this?
    My other questions:
    2° Ive a presentation on which Ive created buttons which tigger pop-up animations
    - i have 5 buttons which trigger animations
    - the viewer can chose to Click on any of the buttons randomly
    - the problem is once the animation is open how can it be close... either:
    a) by it self after "40" seconds
    b) when ther viewer clicks another button
    3° Ive created buttons linking pages..
    - "go to page xxx"
    - when i do a preview and click on the buttons the links dont take me to the right pages
    - is that normal? (maybe in preview its suppose to be like that)
    4° I would like to intergrate YouTube videos in the presentation so they play inside the docment.. when i tried.. it said the 'link isnt a flash video'
    - what should i do?
    5° Once i export it into Swf. how how can i visualize it? or put it online?
    Thank you for your time.

    stlbbl4u wrote:
    Hello,
    Here is the problematic:
    1° How can i change the color of the text on a button in Roll Over or Click state (Cs5.5)
    - I've many button in a doc im creating
    - the color of the buttons is white with black stoke & black text
    - in roll over state i want them to inverse the color coding (the text white & bottom black)
    - currently the text becomes invisible as black on black cant be seen (ive stroked it white but that looks ugly)
    - i would just like to know if there is a function made for this?
    You should setup Object Styles - these can also include Paragarph Styles that can be triggered when the Style is selected.
    http://help.adobe.com/en_US/indesign/cs/using/WS5CEDB81A-0011-4dc9-9DE8-AC7AD4C80076a.html
    My other questions:
    2° Ive a presentation on which Ive created buttons which tigger pop-up animations
    - i have 5 buttons which trigger animations
    - the viewer can chose to Click on any of the buttons randomly
    - the problem is once the animation is open how can it be close... either:
    a) by it self after "40" seconds
    b) when ther viewer clicks another button
    I'm not sure what you mean - I don't do files with Animations
    3° Ive created buttons linking pages..- "go to page xxx"
    - when i do a preview and click on the buttons the links dont take me to the right pages
    - is that normal? (maybe in preview its suppose to be like that)
    Does it work properly when you export it to the finished file?
    4° I would like to intergrate YouTube videos in the presentation so they play inside the docment.. when i tried.. it said the 'link isnt a flash video'- what should i do?
    InDesign won't link directly to youtube videos. I think your best bet would be to use Downloader to download the video and embed them directly in Indesign.
    5° Once i export it into Swf. how how can i visualize it? or put it online? 
    Thank you for your time.
    You can look up how to embed a SWF file into your HTML - but it depends what you mean by "online" there's a dozen ways to get a file "online".

  • How do i change the default hand tool to select tool when a document opens?  also how do i get it to open in a single page view instead of 2 pages side by side

         how do i change the default hand tool to the select tool when i open a document.
    how do i change the view from 2 pages to a single page?

    Try setting the check boxes in Edit>Preferences>General for the following:
    - Make Hand tool select text & images
    - Make Hand tool read articles
    - Make Hand tool use mouse-wheel zooming
    Adjust these as needed but does it make any difference?

  • How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    Okay, I've figured it out, so I'm going to answer my own question in hopes that it may help anyone else that would like to actually be able to see what they're doing when using Photoshop CC 2014 on a high resolution screen.
    1.  Open Photoshop.
    2.  Select Preferences from the Edit Menu, then select General.
    3.  Change the HUD Color Picker to Hue Strip (Medium).
    4.  Select Interface from the Preferences menu on the left side of the dialog box.
    5.  Change the UI Font Size to Large in the Text area of the Preferences dialog box.
    6.  Select Experimental Features from the Preferences menu on the left side of the dialog box.
    7.  Select Scale UI 200% for high-density displays (Windows only).
    8.  Click on OK, then Exit/Quit Photoshop.
    9.  Open Photoshop and everything should be readable.

  • How do I change the font size and color in a text box?

    How do I change the font size and color in a text box?

    Really frustrating to find the first time but simple once you figure it out. I think I spent hours trying to find this. Simply right click on a blank spot in the toolbar up top and select Properties Bar. There it is! The available properties will change depending on whether you have the content (text) selected or the box itself.
    I haven't found a way yet to make it show up as a regular part of the toolbar. It floats around and gets in the way so I don't leave it on and then have to open it again when I need it. Again - frustrating; but at least it's there!

  • How do you change the text font on the Droid Global Phone

    How do you change the text font on the Droid Global Phone. I would like it to be darker (like bold)

    Hi.  
    Below I have provided you with the steps to change your font settings.
    From the main menu
    Select Settings
    Select Display Settings
    Select Font Style
    You can select from what is available, 
    Or you select [Get Fonts Online] to find something you want.
    Thank you,

  • How do I change the Gradient in the Artwork and Effect Text tool

    How do I change the colors used in the gradient under the Artwork and Effects Text Tool? It always comes green and blue and I dont know how to change it.

    Gradient usually picks up the foreground & background colors from the chips in the tool bar, but that is for the default gradients. Sounds like you have one of the pre-set gradients selected in the drop down list in the gradient options bar. Select the gradient tool, then look in the options bar at the top of the screen. The second item from the left, if I remember correctly, is a drop down list of various gradient possibilities. Select the top left gradient sample for the foreground to background gradient.
    Bob Warren

  • How can I change the text in F1 Help?

    I made a General Text  in T-code SE61, the name is 'ZTEST'.
    And at the SE80, in the local program,
    I used functions like these:
    HELP_OBJECT_SHOW
    HELP_OBJECT_SHOW_FOR_FIELD
    DSYS_SHOW_FOR_F1HELP
    These functions can display F1 HELP.
    But I want to send a text using functions,
    and display F1 HELP.
    Example)
    'Hello! This is your program.'
    Sending this to F1 HELP by functions, and display.
    If you know, please help me.
    Thank you.
    Edited by: Jaime White 999 on Apr 19, 2011 9:20 AM

    My source is like this:
    REPORT  z_test008.
    DATA: lt_links TYPE TABLE OF tline.
    SELECTION-SCREEN: PUSHBUTTON 2(6) s_button USER-COMMAND click.
    INITIALIZATION.
      s_button = 'uB3C4uC6C0uB9D0'.
    AT SELECTION-SCREEN.
      CASE sy-ucomm.
        WHEN 'CLICK'.
          CALL FUNCTION 'HELP_OBJECT_SHOW'
            EXPORTING
              dokclass                            = 'TX'
              doklangu                            = sy-langu
              dokname                             = 'Z_TEST'
              doktitle                            = 'Description'
    *          CALLED_BY_PROGRAM                   = ' '
    *          CALLED_BY_DYNP                      = ' '
    *          CALLED_FOR_TAB                      = ' '
    *          CALLED_FOR_FIELD                    = ' '
    *          CALLED_FOR_TAB_FLD_BTCH_INPUT       = ' '
    *          msg_var_1                           = ' '
    *          MSG_VAR_2                           = ' '
    *          MSG_VAR_3                           = ' '
    *          MSG_VAR_4                           = ' '
    *          CALLED_BY_CUAPROG                   = ' '
    *          CALLED_BY_CUASTAT                   =
    *          SHORT_TEXT                          = 'X'
    *          CLASSIC_SAPSCRIPT                   = ' '
            TABLES
              links                               = lt_links
           EXCEPTIONS
             object_not_found                    = 1
             sapscript_error                     = 2
             OTHERS                              = 3.
          IF sy-subrc NE 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
      ENDCASE.
    I just want to know that how can I change the text in F1 HELP, do not use SE61.
    In the source, I want to send the text by functions, and display that.
    Thank you.

  • How can I change the language of the quiz popup "select more answers" in iBooks author?

    Hi all,
    I am relatively new to iBooks author. I've been creating a quiz with multiple answers. When I review my iBook on my iPad and only select one answer, it shows me a popup with the text "select more answers". Does anyone know how to change the language of that box? I'm working in German, iBooks author is set to German... I just can't figure out how I can change the language of that box.
    Any help would be appreciated!

    crsi wrote:
    the popup is in german, when I view the iBook on my Mac in iBooks. So maybe it's somekind of problem with a setting on my iPad? But  the language and region on the iPad is also set to german..
    Yes, what you see in the popup when viewing the book in the iBooks app is supposed to take on the language of the OS.  I don't know why it would not work on your iPad....

  • In the Menu Bar, under File, then Open File, how do I change the selections?

    I have Firefox 11.0 and Windows 5.1 (2007). In Firefox, I click on FILE in the Menu Bar, then OPEN FILE (Ctrl+O), and I see a small box; it says Look in: Mozilla Firefox. Below is a selection of files within the folder Mozilla Firefox. To the left is a column of four other folders: Downloads, My Computer, John, Lori. The last two are obviously two of the folders I've created on my computer, using Windows. But I don't know how they got here! I have no recollection of customizing this particular Firefox menu option by adding those folders, nor can I figure out what to do in order to further customize it. Can anyone tell me: (1) how can I change the original "Look in" option so that it opens with something other than "Mozilla Firefox" (which, after all, I never need to access)? (2) how can I add/delete/change the choices offered in the column on the left, so that different folders are listed? (Currently, if I want to access my Windows folders/files, I first have to minimize the Firefox screen; this seems to me a nice shortcut, but I'd like it to include shortcuts to the folders I use the most, which does not include "Mozilla Firefox"!) (3) Is this actually a Firefox feature, or is it a Windows feature? It does look like Windows (Windows style, Windows folders), but it appears only in the Firefox Menu Bar, along with Bookmarks, Tools, etc. Thanks!

    This sounds like a Windows thing ( You can post a photo and I can tell you for certain). Those folders are Windows system created folders that your computer has had since it was installed, all Firefox does is use the Windows File picker, which is what you see when you open that window. So, to customize you'd have to do that from Windows Explorer (not Firefox).
    The Window should however remember what folder you were in last.

  • How can i  change the column label text in a alv table display

    how can i change the column label text in a alv table display??
    A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
    <i>*  declare column, settings, header object
    DATA: lr_column TYPE REF TO cl_salv_wd_column.
    DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
    get column by specifying column name.
    lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
    set Header Text as null
    lr_column_header = lr_column->get_header( ).
    lr_column_header->set_text( ' ' ).</i>
    My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
    <i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
    i have checked in debugging and the error occured at the statement :
    <i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
    Thanks,
    Suri

    I found it myself how to do it. The error says that it is not able to find the reference object i.e  it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
      DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
             lr_if_controller  TYPE REF TO iwci_salv_wd_table,
             lr_cmdl   TYPE REF TO cl_salv_wd_config_table,
             lr_col    TYPE REF TO cl_salv_wd_column.
      DATA : node_year  TYPE REF TO if_wd_context_node,
             elem_year  TYPE REF TO if_wd_context_element,
             stru_year  TYPE if_alv_layout=>element_importing,
             item_year  LIKE stru_year-i_current_year,
             lf_string    TYPE char(x),
      DATA: lr_column TYPE REF TO cl_salv_wd_column.
      DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    Get the entered value from the input field of the screen
    node_year  = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
    elem_year  = node_year->get_element( ).
      elem_year->get_attribute(
       EXPORTING
        name = 'IMPORT_NODE-PARAMETER'
       IMPORTING
        value = L_IMPORT_PARAM ).
      WRITE L_IMPORT_PARAM TO lf_string.
    Get the reference of the table
      lr_cmp_usage  =  wd_this->wd_cpuse_alv( ).
      IF lr_cmp_usage->has_active_component( ) IS INITIAL.
        lr_cmp_usage->create_component( ).
      ENDIF.
      lr_if_controller  = wd_this->wd_cpifc_alv( ).
      lr_column_settings = lr_if_controller->get_model( ).
    get column by specifying column name.
      IF lr_column_settings IS BOUND.
        lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
    set Header Text as null
        lr_column_header = lr_column->get_header( ).
        lr_column_header->set_text( lf_string ).
    endif.

  • How do I change the color of font in a fillable form in Adobe Reader? How can I check if the writer of the document has given permission to edit color and not just add text?

    How do I change the color of font in a fillable form in Adobe Reader? How can I check if the writer of the document has given permission to edit color and not just add text? Please help! I'm technologically challenged.

    Most forms (99% or more) are created for simple text input, where you cannot change anything.
    The creator of the form could allow Rich Text input (which allows you to change font, text size, color, etc.), but frankly I have never seen such a form, and I wouldn't know how they look.  But I'm sure they would show some kind of controls to alter the text appearance.

  • How can i change the color of the text bubble and change my name instead of having verizion at the top

    how can i change the color of my background on my texting and the bobbles and instead of having verizon at the top i was told i could have my last name

    You cannot.  Customizations such as those are not available in iOS.

  • How can I change (or select) what is being being used when I share, as the file cover. When I Share lets say "Master File" i want to select a frame that is used as the file cover. So when its on my desktop I see this image as the file icon.

    How can I change (or select) what is being being used when I share, as the file cover. When I Share lets say "Master File" i want to select a frame that is used as the file cover. So when its on my desktop I see this image as the file icon.

    I don't think Finder does this (I've tried).
    iTunes does though. Where you can set artwork or the "poster frame"...
    This may not be what you want but if it helps, I know 2 ways  do this is
    Open the video in QuicktimePlayer7 | View | Set Poster Frame (even then, you might need to save it as .mov (ie in a 'mov container').
    Drag the file into iTunes and set the artwork (as in http://www.dummies.com/how-to/content/adding-album-cover-art-or-images-in-itunes .html)
    From there, iTunes will use that frame as the "poster frame" ie the photo/frame that shows when you browse your videos. Which is what you want, but limited to iTunes.
    When I do either of these above, the frame I set does not show when exploring files in "Finder" (or in the other Explorer tool I use called "Pathfinder").
    So it maybe, that exactly what you want, is not possible.

  • How do I change the toolbar menu to show only icons, not icons and descriptive text? Thanks for your help.

    My menu toolbar shows icons with a text to the right of the icon describing it. How do I change the settings so that just the icons show. I'm pretty sure it can be done as I've set my desktop for icons only.

    check under settings/ messages
    or
    settings / notification
    not sure what you are asking or looking for.  kinda hard to follow without my phone infront of me, at work. hope that is some what helpful

Maybe you are looking for

  • Table Required for Delivered Qty field in Sales Order

    Hi friends I can see confirmed order qty, required qty, quantity committed  in VBEP table. But if you see in sales order Schedule Lines you'll see one more field named as Delivered Quantity. I am not able to find this Delivered Qty in any of the SD t

  • All-In-One IdeaCentre C440, high pitch sound

    I have a problem with my Desktop PC All-In-One Lenovo IdeaCentre C440, machine type: 10104, configuration number: 57322047. I bought this computer last week ago and from the beginning is present a high pitch sound. The high pitch sound is more eviden

  • Flash Forms & CFGRID

    I have flash form where I can transfer items between 2 grids. The idea is to take items from grid1 and move to grid2 and on submit it will take items from grid2 and instert them into the database. This part works fine as long as grid2 is empty, but w

  • ECC 6.0 FI Business

    I am looking for SAP standard business process flows for ECC 6.0. We are upgrading our installation and want to mimic our processes to match ECC 6.0 process flows. I have tried to get this information on Solution Composer but it does not have SAP del

  • OS 10.6.8 time machine backups failing on external G-drive 3TB drive firewire connected

    Got  a brand new 3 TB G-DRIVE external and did initial backup with time machine, worked great. Seems to do hourly backups ok, but when it comes to daily/weekly/monthly it takes FOREVER, hanging up everything in the process and fails because it says t