CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Perth - Australia
    Posts
    86

    Set DataCombo Current Selection

    Hi,
    Does anyone know how to set the current selection in the DataCombo control?
    In the Combobox I think there's a SetCurSel method, but this method is not available for the DataCombo control.
    Please help, I've been trying to figure it out the hole day.
    I'm using ADO and the binding code is below.


    _RecordsetPtr rs; //recordset object


    //opens recordset...

    ......

    //sets dataCombo
    m_AnsTyp.putref_RowSource((LPUNKNOWN) rs);
    m_AnsTyp.put_ListField("AnsTypDes");
    m_AnsTyp.put_BoundColumn("AnsTyp");
    m_AnsTyp.put_BoundText("AnsTypDes");

    Thks a lot
    Beatrice

  2. #2
    Join Date
    Sep 2003
    Location
    Brazil
    Posts
    5
    there is a simple (maybe not the best) way:

    string mycurrentselection="3";

    for (int i=0;i<combo.items.count;i++){
    if (mycurrentselection==combo.selecteditem.value){
    combo.selectedindex=i;
    break;
    }
    }


    check the syntax... caps, etc.. of this code, please

    good luck!

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