读书人

listBox1_DrawItem事件无响应?该怎么

发布时间: 2013-06-26 14:29:32 作者: rapoo

listBox1_DrawItem事件无响应?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
MessageBox.Show("hello");
}
}
}


运行后没有显示信息框,不知道是哪里写错了? ListBox
[解决办法]
你有没有把listBox1_DrawItem关联给listBox1.DrawItem?
[解决办法]
修改 DrawMode = OwnerDrawFixed 或者 OwnerDrawVariable

不然它不会激发DrawItem事件


不是每个事件你注册了 就会调用你的事件处理程序 有些事件需要你设置是否激发

读书人网 >C#

热点推荐