本文目录一览:
- [C++ LISTBOX具体用法](#C++ LISTBOX具体用法)
- [C 语言如何改变LISTBOX的颜色](#C 语言如何改变LISTBOX的颜色)
- [c #listbox 的内容怎么复制](#c #listbox 的内容怎么复制)
- [请问C#控件中listBox怎么赋值呀?是listBox.Text="" 吗?](#请问C#控件中listBox怎么赋值呀?是listBox.Text="" 吗?)
- 用C#语言ListBox和MessageBox关联的问题
C++ LISTBOX具体用法
CString t;
int i;
for(i=65; i<70; 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() + "】项;\r\n字母为:" + 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