Clistctrl application

xiaoxiao2021-03-05  22

VC programming environment initialization: DWORD dwStyle; dwStyle = m_bzlist.GetStyle (); dwStyle | = LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_SHOWSELALWAYS; m_bzlist.SetExtendedStyle (dwStyle); m_bzlist.SetBkColor (RGB (0xec, 0xf1,0xfd)); m_bzlist.SetTextBkColor ( RGB (0xfe, 0xff, 0xc6); insert a column: m_bzlist.insertColumn (0, "Number"); m_bzlist.setColumnWidth (0, 50); Insert a line: LV_Item LVItem; lvitem.psztext = "; lvitem .mask = lvif_text; lvitem.isubitem = 0; lvitem.iitem = 0; m_jbxxlist.insertitem (& lvitem); m_jbxlist.setitemtext (0, 0, xh); m_jbxxlist.setitemtext (0, 1, xm); m_jbxxlist.setitemtext 0, 2, NJ); Method 2: M_YKTList.Insertitem (i, "2"); m_yktlist.setitemtext (i, 0, s); m_yktlist.setitemtext (i, 1, xh); m_yktlist.setitemtext (i, 2 , XM); read data ResultList.getItemText (number of lines, columns); list with check boxes per line: Using lvs_ex_checkboxes attribute DWord DWStyle; dwstyle = m_yktlist.getStyle (); dWStyle | = lvs_ex_fullrowselect | Lvs_ex_checkboxes; m_yktlist.seXtendedStyle (DWStyle); Settings: m_yktlist.setitemstate (number of lines, 0x2000, lvis_stateImageMask); // Set to selected status determination: m_yktlist.getItemState Number of lines, lvis_stateImagemask == 0x2000 // Select the clicking column sort:

Define lists that can be sorted, only need to define two variables Class SortClistCtrl: Public ClistCtrl {// constructionpublic: SortClistCtrl ();

// attributespublic: bool m_fasc; // Whether or not the order sorting int m_nsortedcol; // The current sorted column ....} Instantiate your own variables in use when using the list of variables SortClistCtrl m_yktlist;

// Response Click Column Function Void CauditingCertview :: OnColumnClickListykt (NmHDR * PNMHDR, LRESULT * PRESULT) {for (int i = 0; i iSubItem == m_yktlist.m_nSortedCol) m_yktlist.m_fAsc = m_yktlist.m_fAsc;! else {m_yktlist.m_fAsc = True; m_yktlist.m_nsortedcol = pnmlistview-> isubitem;} // Call the sort function, this function is defined for CListCtrl, but you need to call our defined function to compare the value of any two items M_YKTList.SortItems (MyListCompare, (LPARAM ) & m_yktlist); for (i = 0; i

/// Global function, compare two items based on int Callback MyListCompare (LParam LPARAMSORT) {// By passing parameters to get CSortlist object pointers, to get sorted mode SortClistCtrl * PV = (SortClistCtrl *) lParamSort; // data determined by ItemData CString szComp1, szComp2; int iCompRes; szComp1 = pV-> GetItemText (lParam1, pV-> m_nSortedCol); szComp2 = pV-> GetItemText (lParam2, pV-> m_nSortedCol); switch (pV -> m_nsortedcol) {case (0): // With the first list as the sort number ICOMPRES = ATOF (SZCOMP2) <= ATOF (SZCOMP2)? - 1: 1; Break; Case (4): // Take 5 List as the total number of sorting ICOMPRES = ATOF (SZCOMP1) <= ATOF (SZCOMP2)? - 1: 1; Break; default: iComprees = szcomp1.compare (szcomp2); Break;} // Adjust IF according to current sorting (pv-> m_fasc) Return iCompres; else return -icompres;}

Export data Use ODBC to excel files to excel data area Void Exportasexcel (CSTRING FileName, ClistCtrl & Resultlist, CWnd * Wnd) {cdatabase Database; CString SDriver = "Microsoft Excel Driver (* .xls)"; // Excel Installation Drive CSTRING SSQL, Sexcelfile; // Pop-up dialog Select Path CFiledialog Filedlg (false, "path", filename, OFN_FILEMUSTEXIST | OFN_HIDEREADOSTEXIST | OFN_HIDEREADOSLY, "* .XLS", WND); if (filedlg.domodal () == idok) {sexcelfile = Filedlg.getPathname (); // To create the Excel file cfilefind Finder; Bool BWORKING = Finder.findFile (SEXCELFILE); // Looking for File IF (BWORKING) // Remove {CFile :: Remove (( LPCTSTR);}}}}}} else return; try {// Create a string SSQL.Format ("driver = {% s}; DSN = '; firStrowhasNames = 1; readonly = false; create_db = /" % s / "; dbq =% s", sdriver, sexcelfile, sexcelfile; // creation database (both EXCEL table file) IF (Database.openex (SSQL, CDatabase :: noodbcdialog) {CHEADERCTRL * PHEADER = ResultList.getHeaderCtrl (); // Get the number of lines, the number of int ncolcount = phetlist.get (); int nlineCount = resultList.getItemcount (); int colorDeray [100]; cstring CA [100]; ResultList.getColumnRray (colorDeray, ncolcount); // Retrieves the information of each column, determine the content for the column title for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-35881.html

New Post(0)