• listcontrol 加combobox实现


    头文件

    #pragma once
    #include "D:Work山东项目StandardizedDrawingsdUtilsCSGrid.h"
    #include "ZwLResources.h"
    class CPaneGrid :
    public CSGrid
    {
    public:
    CPaneGrid(void);
    ~CPaneGrid(void);
    protected:
    DECLARE_MESSAGE_MAP()
    protected:
    virtual VOID OnCellComboString(CSGridCell&cell, CComboBox&combo);
    // virtual VOID OnRClickRow(CSGridRow&row, CPoint point);
    // virtual VOID OnRClickCol(CSGridCol&col, CPoint pt);
    // virtual BOOL OnRowSelectChange(int nOldRow, int &nNewRow);
    };

     cpp文件

    #include "StdAfx.h"
    #include "PaneGrid.h"
    #include "OdbcDatabase.h"
    #include "GlobalArxUtils.h"
    #include "GlobalUtils.h"
    #include "CSGrid.h"


    CPaneGrid::CPaneGrid() :CSGrid(FALSE)
    {
    AppendColumn(_T("属性名称"), 70);
    AppendColumn(_T("值"), 120);
    GetCol(GetColumnCount() - 1).SetComboEdit(TRUE);
    }
    BEGIN_MESSAGE_MAP(CPaneGrid, CSGrid)
    END_MESSAGE_MAP()
    CPaneGrid::~CPaneGrid(void)
    {
    }
    VOID CPaneGrid::OnCellComboString(CSGridCell&cell, CComboBox&combo)
    {
    long lIndexRow = cell.GetRowIndex();
    long lIndexCol = cell.GetColIndex();
    CSGridCell cellNmae=CSGrid::GetCell(lIndexRow, lIndexCol-1);
    CString ProName=cellNmae.GetText();
    CString sDatabase;
    sDatabase.Format(_T("%sData\%s"), GetAppRoot(), SDDATABASE);
    COdbcDatabase db;
    CString sQuery;
    CStringList slResults;
    CString sValue;
    if (db.InitializeWithPath(sDatabase))
    {
    sQuery.Format(
    _T("SELECT AlternativeValue FROM ")
    _T("%s ") _T("WHERE [PropertyName] = '%s'"),
    TABLE_CUSTOMPROPERTY, ProName);
    slResults.RemoveAll();
    db.GetQuery(sQuery, slResults);
    }
    POSITION rPos;
    rPos = slResults.GetHeadPosition();
    while (rPos != NULL)
    {
    sValue = slResults.GetNext(rPos);
    //拆分字符串
    CStringArray saCf;
    int iPos = -1;
    while ((iPos = sValue.Find(',')) != -1)
    {
    saCf.Add(sValue.Left(iPos));
    sValue.Delete(0, iPos + 1);
    }
    saCf.Add(sValue);
    int iNum=saCf.GetCount();
    for (int i = 0; i < iNum;i++)
    {
    combo.AddString(saCf.GetAt(i));
    }
    }
    return CSGrid::OnCellComboString(cell, combo);
    }

    重定义csgrid 然后用新定义的类去创建函数

  • 相关阅读:
    android中Canvas使用drawBitmap绘制图片
    Java Metrics
    HDU 1051:Wooden Sticks
    APK ubuntu下 数字签名
    Qt计算器开发(二):信号槽实现数学表达式合法性检查
    session销毁
    C#多线程编程实例 螺纹与窗口交互
    POJ 1176 Party Lamps (DFS)
    Oracle 六闪回技术,flashback
    can&#39;t connect to mysql server on localhost &lt;10061&gt;
  • 原文地址:https://www.cnblogs.com/xzh1993/p/4797735.html
Copyright © 2020-2023  润新知