我经常在对话框中使用DBGrid控件,也就是通过DBGrid和Microsoft RemoteData Control控件同时使用,将DataSource属性进行绑定,但是对DBGrid在视图中的使用不太清楚,我正在做一个程序,需要在视图中使用DBGrid,特请教高手??

解决方案 »

  1.   

    我也在开始也用DBGRID,但是发现有不少问题,用MSFLEXGRID也不错你看看msdn中的这篇文章:
    PRB: DBGrid Control Not Fully Functional in VC++但是用DBGRID做绑定用还是够用了,
    在视图中应用,如果用CFORMVIEW,那就和在DLG中一样使用,要不就用CREATE(...)了
      

  2.   

    用m_DbGrid.ShowWindow(SW_HIDE)  /SW_SHOW不行吗
      

  3.   

    选择project->add to project->components and controls->Registered ActiveX Controls->Controls you wanted,按下Insert,在视图窗类的头文件中加入控件所需的头文件,并定义一个控件对象,如CDBGrid m_dbGrid。然后在CView::Ondraw()中绘制出来m_dbGrid.MoveWindows(rcClient),rcClient表示客户区矩形。当然最好在此之前加上判断if(m_dbGrid.IsWindow()),看一看,好象控件出来了,就这样。
      

  4.   

    SAMPLE: AdoDataGrid.exe Demonstrates How to Use ADO with DataGrid Control Using Visual C++ Q229029http://download.microsoft.com/download/ado/Utility/1.0/WIN98/EN-US/AdoDataGrid.exe
    The AdoDataGrid sample is a FormView-based SDI MFC application. All the files are wizard-generated. After inserting the ActiveX object (Microsoft DataGrid control), the wizard will provide CColumn, CColumns, CDataFormatDisp, CDataGrid, COleFont, CPicture, CSelBooks, CSplit, CSplits, and CStdDataFormatsDisp classes in their respective files. No modification was made in DataGrid and its dependent files for this sample. In this sample, code for manipulating ADO objects is located in AdoDataGridView.cpp. The #import statement for ADO is located in Stdafx.h.