locked
Preencher primeiro item do combobox com a palavra SELECIONE RRS feed

  • Question

  • Amigos,

    eu carrego um combobox dessa forma: 

    ...

                    CProfissao CPro = new CProfissao(BDC);
                    dttProfissao = CPro.buscarProfissao();


                    this.cbProfissao.DataSource = dttProfissao;
                    this.cbProfissao.DisplayMember = "pro_nome";
                    this.cbProfissao.ValueMember = "pro_codigo";

    ...

    Os dados vem do método buscarProfissao, ok?

    Eu preciso que no primeiro item seja exibido (como displayMember) --SELECIONE-- e (como valueMember) o valor -1. 

    Tem como fazer isso??? Procurei na net sobre isso, MANTENDO  a estrutura com DataSource, DisplayMember e ValueMember, mas NÃO encontrei. É impossível??? valeu!!

    • Moved by Amanda Zhu Tuesday, September 10, 2013 7:05 AM
    Monday, September 9, 2013 6:02 PM

Answers

All replies

  • É sempre assim: vc passa 3 dias procurando... qdo resolve pedir ajuda, desce o texto, explica o que quer... continua procurando e... acha.

    fiz assim: 

    Mexi no meu SQL, no CPro.buscarProfissao();

    ---------------

                DataTable Dtt;
                string sql = @"Select 0 as pro_codigo, '' as pro_nome UNION SELECT * FROM Profissao";
                conexao.executeQuery(sql, out Dtt);
                return Dtt;

    -------------------------------

    assim ele volta o o valor 0 para um campo vazio. Agora vou por só um valor entre as benditas aspas... 

    anyway, 

    thx, bro.

    Monday, September 9, 2013 6:22 PM
  • Hello,

    Since we just support the English language issue, you would select the correct language forum for this specific issue. I will move this thread to the Off-Topic forum.

    Thanks for your understanding.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 10, 2013 7:04 AM
  • Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    • Proposed as answer by Just Karl Wednesday, October 16, 2013 8:32 PM
    • Marked as answer by Just Karl Wednesday, October 30, 2013 2:20 PM
    Tuesday, September 10, 2013 9:48 PM