zoukankan      html  css  js  c++  java
  • 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 然后用新定义的类去创建函数

  • 相关阅读:
    自定义Collection类
    基本排序算法(冒泡排序,选择排序,插入排序)
    泛型
    XSD的学习
    SSH整合配置
    一个可以随时插入的json的简单实现
    将Properties文件的键值对调换位置重新生成一个文件
    JAVA MD5加密
    框架中退出登录
    java 生成 xml
  • 原文地址:https://www.cnblogs.com/xzh1993/p/4797735.html
Copyright © 2011-2022 走看看