Ir para conteúdo
Fórum Script Brasil
  • 0

checklistbox + edit


Manoel Zancheta

Pergunta

5 respostass a esta questão

Posts Recomendados

  • 0
Alguém conhece algum componente parecido com a mescla de um checklistbox + edit? Ou seja, quando selecionar o checklistbox, o edit fica ativo para digitar algo.

Coloque um componente CheckBox e um Edit ao lado dele no form e use o código abaixo

procedure TForm1.FormActivate(Sender: TObject);
begin
   CheckBox1.Checked := false;
   Edit1.Enabled := false;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
   if CheckBox1.Checked = true then
      begin
         Edit1.Enabled := true;
         Edit1.Clear;
         Edit1.SetFocus;
      end
   else
      begin
         Edit1.Clear;
         Edit1.Enabled := false;
      end;
end;

abraço

Link para o comentário
Compartilhar em outros sites

  • 0
Preciso para um CheckListBox e não CheckBox.

Manoel não é tão dificil fazer a mudança

Veja:

procedure TForm1.FormActivate(Sender: TObject);
var i : Integer;
begin
   // limpar e desabilitar os Edits
   for i := 0 to ComponentCount -1 do
    begin
      if Components[i] is TEdit then
         begin
            TEdit(Components[i]).Clear;
            TEdit(Components[i]).Enabled := false;
         end;
   end;
end;

procedure TForm1.CheckListBox1Click(Sender: TObject);
var i : Integer;
begin
   // Verificar os itens não checados do CheckListBox e desabilitar os Edits correspondentes
   for i := 0 to ComponentCount -1 do
    begin
      if Components[i] is TCheckListBox then
         begin
            if TCheckListBox(Components[i]).Checked[CheckListBox1.ItemIndex] = false then
               begin
                  case CheckListBox1.ItemIndex of
                   0 : Edit1.Enabled := false;
                   1 : Edit2.Enabled := false;
                   2 : Edit3.Enabled := false;
                  end;
               end;
         end;
   end;

   
   // Verificar qual item do CheckListBox foi clicado e habilitar o Edit correspondente
   if CheckListBox1.Checked[CheckListBox1.ItemIndex] then
      begin
         case CheckListBox1.ItemIndex of
          0 : begin
                 Edit1.Enabled := true;
                 Edit1.SetFocus;
              end;
          1 : begin
                 Edit2.Enabled := true;
                 Edit2.SetFocus;
              end;
          2 : begin
                 Edit3.Enabled := true;
                 Edit3.SetFocus;
              end;
         end;
      end;
end;

abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...