Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 3 của 3
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Mã:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (listBox1.Items.Count > 0)
                {
                    for (int i = 0; i < listBox1.Items.Count; i++)
                    {
                        if (listBox1.GetSelected(i) == true)
                        {
                            if (listBox1.SelectedIndex >= 0)
                                textBox1.Text = listBox1.Items[listBox1.SelectedIndex].ToString();
                        }
                    }
                }
    
            }
        }
    }
    ý bạn là thế này !!! sử dụng sự kiện selectedIndexChanged của listbox

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Hiển thị nội dung listbox lên textbox

    Đây là code mình làm nhưng không hiển thị được
    Mã:
            private void frmFont_Load(object sender, EventArgs e)
            {
                if (listBox1.Items.Count > 0)
                {
                    for (int i = 0; i < listBox1.Items.Count; i++)
                    {
                        if (listBox1.GetSelected(i) == true)
                        {
                            if (listBox1.SelectedIndex >= 0)
                                txtFont.Text = listBox1.Items[listBox1.SelectedIndex].ToString();
                        }
                    }
                }
            }

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    cám ơn bạn nhé .

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •