社区
VCL组件使用和开发
帖子详情
我要在ListView里面点击某个格子时候,显示一个ComboBox进行选择,请教各路高手
smxn
2003-10-17 10:13:04
我要在ListView里面点击某个格子时候,显示一个ComboBox进行选择,请教各路高手
...全文
58
11
打赏
收藏
我要在ListView里面点击某个格子时候,显示一个ComboBox进行选择,请教各路高手
我要在ListView里面点击某个格子时候,显示一个ComboBox进行选择,请教各路高手
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ccrun.com
2003-12-15
打赏
举报
回复
怎么全是up的。楼主呢,也不吭一声。
liuliuisme
2003-12-15
打赏
举报
回复
up
「已注销」
2003-12-15
打赏
举报
回复
关注
边学边用边创造
2003-12-12
打赏
举报
回复
up
边学边用边创造
2003-12-12
打赏
举报
回复
up
ccrun.com
2003-12-12
打赏
举报
回复
仿季大侠的代码给你写了一份:
在Form上添加一个ListView和一个ComboBox,并适当添加些数据。
// .h file
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TListView *ListView1;
TComboBox *ComboBox1;
void __fastcall ListView1DblClick(TObject *Sender);
void __fastcall ComboBox1Exit(TObject *Sender);
private: // User declarations
int nCol;
TListItem *Item;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
// .cpp file
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ListView1->RowSelect = true;
ListView1->ViewStyle = vsReport;
ComboBox1->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListView1DblClick(TObject *Sender)
{
int nWidth, nHeight;
int nX, nY;
int nCount;
TRect Rect;
TPoint Pos;
Pos = ListView1->ScreenToClient(Mouse->CursorPos);
Item = ListView1->GetItemAt(Pos.x, Pos.y);
if (Item==NULL)
//没有点在Item上
return;
nCount = ListView1->Columns->Count;
nX = -GetScrollPos(ListView1->Handle, SB_HORZ);
for(nCol=0; nCol<nCount; nX+=nWidth, nCol++)
{
nWidth = ListView_GetColumnWidth(ListView1->Handle, nCol);
if (Pos.x <= nX + nWidth)
break;
}
if (nCol == nCount)
return;
if (nX < 0)
{
nWidth += nX;
nX = 0;
}
ComboBox1->Visible = true;
ActiveControl = ComboBox1;
Rect = Item->DisplayRect(drBounds);
Pos.x = nX;
Pos.y = Rect.Top;
MapWindowPoints(ListView1->Handle, Handle, (POINT*)&Pos, 1);
ComboBox1->SetBounds(Pos.x, Pos.y-1, nWidth, Rect.Height()+2);
ComboBox1->Text = nCol==0 ? Item->Caption : Item->SubItems->Strings[nCol-1];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Exit(TObject *Sender)
{
ComboBox1->Visible = false;
if (nCol == 0)
Item->Caption = ComboBox1->Text;
else
{
while(Item->SubItems->Count < nCol)
Item->SubItems->Add("");
Item->SubItems->Strings[nCol-1] = ComboBox1->Text;
}
}
//---------------------------------------------------------------------------
chifengwatch
2003-12-12
打赏
举报
回复
搜索一下
tg1965
2003-10-17
打赏
举报
回复
几年前做过一个,代码忘记了,大概是在那个格子里NEW一个ComboBox.然后初始化那个ComboBox
就可以了.
我不懂电脑
2003-10-17
打赏
举报
回复
搜索一下吧,老问题了。
iris_zhu
2003-10-17
打赏
举报
回复
常听大家说自己画一个,怎么画呀?我也想知道!能不能举个例子呀!
smxn
2003-10-17
打赏
举报
回复
请教各路大侠!
横向
ListView
的完整实现 包含基于横向
listview
做的
一个
小相册demo
横向
ListView
的完整实现 包含基于横向
listview
做的
一个
小相册demo 具体过程参见:http: blog csdn net yanzi1225627 article details 21294553
ListView
滑动删除 ,仿腾讯QQ 源码程序
ListView
滑动删除 ,仿腾讯QQ的源码
android
listView
顶部悬浮效果实现
android简单方式实现
listview
顶部悬浮将
Android实现
ListView
的A-Z字母排序和过滤搜索功能完整实例源码
Android实现
ListView
的A-Z字母排序和过滤搜索功能,完整源码,小伙伴需要的来CSDN下载吧!项目详情http://blog.csdn.net/xiaanming/article/details/12684155
RecyclerView 瀑布流、
ListView
、GridView实例源码
代码为博客实例代码,http://blog.csdn.net/lmj623565791/article/details/45059587 有问题请博客留言
VCL组件使用和开发
604
社区成员
13,460
社区内容
发帖
与我相关
我的任务
VCL组件使用和开发
C++ Builder VCL组件使用和开发
复制链接
扫一扫
分享
社区描述
C++ Builder VCL组件使用和开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章