vc中listview 如何实现双击

我想通过双击listview中的选项来触发事件,但是如何实现listview的双击功能囊,请给予代码和适当的注释,我需要的是SDK的方法不是MFC谢谢拉我想在这段代码中实... 我想通过双击listview中的选项来触发事件,但是如何实现listview的双击功能囊,请给予代码和适当的注释,我需要的是SDK的方法 不是MFC
谢谢拉
我想在这段代码中实现
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
{
MessageBox(hwnd,TEXT("你好"),TEXT("问好"),MB_OK);
}
break;
default:
break;
}
}
你看如何写case语句
IDC_OK是int型 是一个按钮控件的ID
展开
 我来答
johnny_8379
2010-04-27 · TA获得超过210个赞
知道小有建树答主
回答量:198
采纳率:0%
帮助的人:192万
展开全部
/// <summary>
/// 双击选择产品
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listView1_DoubleClick(object sender, EventArgs e)
{
SetListInfo();
}
/// <summary>
/// 将用户选择的产品信息列显示到DataGridView
/// </summary>
private void SetListInfo()
{
listView1.MultiSelect = false;
try
{
if (listView1.SelectedIndices.Count > 0)
{
string str0 = null, str1 = null, str2 = null;

//获取所选ListView的行信息
foreach (int i in this.listView1.SelectedIndices)
{
str0 = this.listView1.Items[i].SubItems[0].Text.ToString();
str1 = this.listView1.Items[i].SubItems[1].Text.ToString();
str2 = this.listView1.Items[i].SubItems[4].Text.ToString();

}

if (CheckValue(str0) == true)
{
_count = (int)_dv.Tag;
_dv.Rows[_count].Cells[0].Value = str0;
_dv.Rows[_count].Cells[1].Value = str1;
_dv.Rows[_count].Cells[2].Value = str2;

_dv.Tag = _count + 1;

//当DataGridView显示的行数达到当前最大行数时,行数自增1
if ((int)_dv.Tag > 6)
{
_dv.Rows.Add(1);
}
this.Dispose();
}
else
{
MessageBox.Show("您已经选择过此列商品信息,请确认后重新选择!", "提示^^", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else
{
MessageBox.Show("请选择一行商品信息列后再单击按钮!", "提示^^", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}

catch (Exception el)
{
MessageBox.Show(el.Message);

}
}
/// <summary>
/// 根据货号判断用户是否重复选择
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public bool CheckValue(string str)
{
bool value = true;
for (int i = 0; i < (int)_dv.Tag; i++)
{
if (_dv.Rows[i].Cells[0].Value.ToString().Trim().Equals(str.Trim()))
{
value = false;
}
}
return value;
}

以上功能是双击LISTview后把数据选择的数据传给另一个窗体里的DATAVIEW


int id;
id 是INT型的,IDC_OK是什么类型????
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式