首页 > 编程知识 正文

关于c语言listbox的信息

时间:2024-03-07 18:23:12 阅读:331564 作者:EQXC

本文目录一览:

C++ LISTBOX具体用法

CString t;

int i;

for(i=65;i70;i++)

{

t.Format("%c",i);

m_lst.AddString(t);//m_lst是控件变量

}

C 语言如何改变LISTBOX的颜色

在列表框所在的对话框里处理WM_CTLCOLORLISTBOX消息,并返回一个有颜色的刷子(HBRUSH)。

//这是MFC下的

HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{

// HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here

// TODO: Return a different brush if the default is not desired

static HBRUSH hbr=NULL;

if(hbr==NULL)

{

//创建红色刷子

hbr=CreateSolidBrush(RGB(255,0,0));

}

//如果是列表框

if(pWnd-GetDlgCtrlID()==IDC_LIST1)

{

pDC-SetBkMode(TRANSPARENT);

return hbr;

}

return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

}

//不用MFC的话思路是也一样的。

//如果还不行直接找我!!

c #listbox 的内容怎么复制

private void test()

{

for (int i = 0; i listBox1.Items.Count; i++)

{

listBox2.Items.Add(listBox1 .Items [i]);

}

}

请问C#控件中listBox怎么赋值呀?是listBox.Text="" 吗?

listBox有一个这样的属性:Items,你可利用它进行赋值:

listBox1.Items.Add("a");

listBox1.Items.Add("b");

listBox1.Items.Add("c");

用C#语言ListBox和MessageBox关联的问题

我给你做了个一摸一样的:在窗体中拖进个listbox1:代码如下:

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)

{

MessageBox.Show("您选的是:第【"+(listBox1.SelectedIndex + 1).ToString() + "】项;rn字母为:" + listBox1.SelectedItem.ToString());

}

private void Form1_Load(object sender, EventArgs e)

{

string[] myString = new string[]{"A","B","C","D","E","F","G","H", "I","J","K","L","M","N","O","P","Q","R","S","T","U",

"V","W","X","Y","Z"};

for (int i = 0; i myString.Length; i++)

{

listBox1.Items.Add(myString[i]);

}

}

可以加我百度HI,共同了解ASP.NET

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。