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 然后用新定义的类去创建函数

  • 相关阅读:
    JS站点
    1011 World Cup Betting (20分)
    1007 Maximum Subsequence Sum (25分)(动态规划DP)
    1006 Sign In and Sign Out (25分)
    1005 Spell It Right (20分)
    1004 Counting Leaves (30分)(DFS)
    1003 Emergency (25分)(Dijkstra算法)
    1002 A+B for Polynomials (25分)
    1001 A+B Format (20分)
    canvas
  • 原文地址:https://www.cnblogs.com/xzh1993/p/4797735.html
Copyright © 2011-2022 走看看