vsflexgrid¼¼ÇÉ´óÈ«ÈçºÎʵÏÖ½«vsflexgridÖÐÐ޸ĵÄÊý¾Ý·´À¡µ½Êý¾Ý¿âÖУ¿£¿PrivateSubvsflexgrid1_AfterEdit(ByValRowAsLong,ByValColAsLong)rs.MoveFirst'//rsΪ¼Ç¼¼¯rs.Movevsflexgrid1.Row-1rs.EditIfvsflexgrid1.text=Thenrs.Fields(vsflexgrid1.Col-1)=NullElsers.Fields(vsflexgrid1.Col-1)=vsflexgrid1.textEndIfrs.UpdateendsubÒ»¡¢Ôö¼Ó¼Ç¼ʹÓÃforÀ´Ñ»·±í¸ñÐС£fori=1togrid1.rows-1withrs.addnew.fileds(o)=grid1.textmariy(i,0).fileds(1)=grid1.textmariy(i,1).fileds(2)=grid1.textmariy(i,2).fileds(3)=grid1.textmariy(i,3).updateendwithnext¶þ¡¢Ìí¼ÓÐС¡¡¡grid1.additemrowÈý¡¢É¾³ýµ±Ç°ÐС¡¡¡withgrid1i=.row.removeitemiendwithËÄ¡¢ÒªÏÔʾÏÂÀ¿ò£¬¿ÉÒÔʹÓÃvsflexgridÖÐÁа󶨹¦ÄÜ¡¡¡¡grid1.colcombolist(1)£½grid.buildcombolist(rs,ÉÌÆ·Ãû³Æ)¸úÂ¥ÉϵÄÏà±È,½ö½öÊÇdatamode²»Ò»Ñù(2-flexDMBoundBatch)µ«ÕâÑù×öµÄÓÅÊÆÊǷdz£Ã÷ÏÔµÄ:¿ÉÒÔ³·Ïú°üÀ¨ÐÂÔöɾ³ýÔÚÄÚµÄËùÓвÙ×÷,°´±£´æ¼ü²ÅдÈëÊý¾Ý¿âPrivateSubCmdDel_Click()Iffg.Row0Thenfg.RemoveItem(fg.Row)fg.RefreshEndSubPrivateSubCmdAdd_Click()OnErrorResumeNextAdodc1.Recordset.AddNewIfErr.Number0ThenMsgBoxErr.DescriptionEndSubPrivateSubCmdUpdate()Adodc1.Recordset.UpdateBatchadAffectAllChaptersEndSubPrivateSubCmdCancel_Click()Adodc1.Recordset.CancelBatchfg.DataRefreshEndSubPrivateSubForm_Load()Adodc1.ConnectionString=FILENAME=&App.Path&\conn.dsnAdodc1.LockType=adLockBatchOptimisticAdodc1.RecordSource=Your_TablenameSetfg.DataSource=Adodc1EndSub1¡¢´òÓ¡vsflexgrid¿ÉÒÔʹÓÃvsprinter´òÓ¡¿Ø¼þ¡£¸úvsflexgridÅäÌ×ʹÓÃЧ¹û²»´í¡£2¡¢µ¼³öEXECL£¬¿ÉÒÔʹÓÃgrid.savegridµÄ·½·¨¡£ÓÃsavegridµÄ·½·¨£¬ÔÚµ¼³öexeclʱ£¬Èç¹ûÅöµ½ÀàËÆÓÚÒøÐÐÕʺŵÄÁÐÈ磺¡°£¶£´£¶£µ£´£µ£¶£¶£¶£µ¡±£¬µ¼µ½£Å£Ø£Å£Ã£ÌÖоͲ»ÕâÑùÏÔʾÁË£¬Õâ¸öÎÊÌ⻹²»ÖªµÀÔõô½â¾ö£¿£¿ÁíÍâÒ²¿ÉÒÔд´úÂ루Õâ¸ö·½·¨±È½ÏʵÓ㬵«ÂýһЩ£©£ºDimexcelAppAsExcel.ApplicationSetexcelApp=NewExcel.ApplicationOnErrorResumeNextIfexcelAppIsNothingThenSetexcelApp=CreateObject(Excel.application)IfexcelAppIsNothingThenExitSubEndIfEndIfexcelApp.Visible=TrueMe.MousePointer=vbHourglassexcelApp.Workbooks.AddWithexcelApp.ActiveSheetDimiAsInteger,jAsIntegerFori=1ToGrid1.rowsForj=1ToGrid1.Cols.Cells(i,j).value='&Grid1.TextMatrix((i-1),(j-1))'¼ÓÉÏ¡°'¡±ºÅÔò¿ÉÒÔ½â¾öÉÏÃæsavegridÖÐÒøÐÐÕʺŵĵ¼³öÎÊÌâ¡£NextjDoEventsNextiEndWithMe.MousePointer=vbDefaultSetexcelApp=NothingEndSubEXCELͬVsflexgridͨ¹ý×î½üºÜ¶àµÄÅóÓÑ,¶¼ÏëÖªµÀEXCELÔõÑùͬVSflexgrid½»»»Êý¾Ý¡£Êµ¼ÊÉÏ£¬ÀûÓá°¸´ÖÆ¡±¡¢¡°Õ³Ìù¡±²Ëµ¥¼´¿ÉʵÏÖ¡£¾ßÌåÈçÏ£º£¨1£©ÔÚVsflexgridÉϵ¯³öÓÒ¼ü²Ëµ¥PrivateSubgrid1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,yAsSingle)ifButton=2ThenPopupMenumnutccdEndSub£¨2£©ÉèÖø÷²Ëµ¥µÄÄÚÈÝA¸´ÖÆClipboard.ClearClipboard.SetTextgrid1.ClipB¼ôÇÐDimrowcAsLongDimrowzAsLongDimcolcAsLongdimcolzAsLongdimiaslongdimsaslongIfgrid1.Rows=1ThenExitSubClipboard.ClearClipboard.SetTextgrid1.ClipIfgrid1.RowSelgrid1.rowThenrowc=grid1.rowrowz=grid1.RowSelElserowc=grid1.RowSelrowz=grid1.rowEndIfIfgrid1.ColSelgrid1.ColThencolc=grid1.Colcolz=grid1.ColSelElsecolc=grid1.ColSelcolz=grid1.ColEndIfFori=rowcTorowzFors=colcTocolzgrid1.TextMatrix(i,s)=NextNextCÕ³Ìù£¨¾«»ª²¿·Ö)DimiAsLongDimsAsLongDimmAsLongDimtAsLongIfgrid1.Rows=1ThenExitSubt=Len(Clipboard.GetText)Ift=0ThenExitSubFori=1TotIfMid(Clipboard.GetText,i,1)=Chr(9)Thens=s+1IfMid(Clipboard.GetText,i,1)=Chr(13)Thenm=m+1NextIfs/(m+1)+grid1.Colgrid1.Cols-1Thengrid1.ColSel=grid1.Cols-1Elsegrid1.ColSel=s/(m+1)+grid1.ColEndIfIfgrid1.row+mgrid1.Rows-1Thengrid1.RowSel=grid1.Rows-1Elsegrid1.RowSel=grid1.row+mEndIfgrid1.Clip=Clipboard.GetTextVSFlexGrid³£ÓÃÊôÐÔ»ò·½·¨£º.FixedRows=1'¹Ì¶¨¼¸ÐÐ.FixedCols=1'¹Ì¶¨¼¸ÁÐ.Editable=True'ÔÊÐíÐÞ¸Ä.AllowUserResizing=flexResizeBoth'¿Éµ÷ÕûÐÐ/ÁÐ.FocusRect=flexFocusNone'ÎÞÐé¿ò.SelectionMode=flexSelectionListBox'½¹µãÑ¡ÖÐÑùʽ.BackColor=RGB(255,255,255)'µ¥Ôª±³¾°É«.BackColorSel=vbBlue'µ¥ÔªÑ¡ÔñÉ«.BackColorFixed=RGB(208,192,160)'¹Ì¶¨µ¥ÔªÉ«.BackColorAlternate=RGB(255,250,230)'¼ä¸ôÐб³¾°É«.GridColor=RGB(245,240,210)'µ¥ÔªÏßÌõÉ«.ForeColor=RGB(0,0,0)'µ¥ÔªÇ°¾°É«(×Ö·ûÉ«).RowHeightMin=260'×îСÐиß.RowHeightMax=800'×î´óÐиß.ColHeightMin=50'×îСÁпí.ColHeightMax=3000'×î´óÁпí.ColWidth(Col)=1000'Ö¸¶¨Áпí.RowHeight(Row)=260'Ö¸¶¨Ðиß.TextMatrix(Row,Col)=Text'Ö¸¶¨µ¥Ôª×Ö·û.Text=Text'Ñ¡¶¨µ¥Ôª×Ö·û.MergeCol(Col)=True'ÔÊÐíºÏ²¢ÁÐ.MergeRow(Row)=True'ÔÊÐíºÏ²¢ÐÐ.MergeCells=0|1|2|3|4|5|6'ºÏ²¢Ñ¡Ïî.Cell(Ñ¡Ïî×¼Ôò,Row1,Col1,Row2,Col2)'Ñ¡Ôñ²¿·ÖµÄÏàӦ׼ÔòÖµ.EditCell'µ±Òƶ¯µ½µ±Ç°µ¥ÔªÊ±×Ô¶¯Ñ¡Ôñ.EditSelStart'Òƶ¯µ½µ¥ÔªÊ±µÄ¹â±êλÖÃ.MousePointer'ÉèÖöÔÏóµÄÊó±êÖ¸ÕëÑùʽO.A=0µ½15|99©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥¼¸¸öÌØÊâµÄÊôÐÔ·½·¨µÄʹÓãºFormatStringÊôÐÔ£º¹ÜµÀ·û¸ñʽ»¯×Ö·û´®Ê¾Àý£ºÏÂÃ涨Òå¶ÔÆ뷽ʽͬ×ÖÒ⣬ÁпíÕͬ¾àÀëVSG1.FormatString=^ÖÐ|×ó|ÓÒ|ÓÒ|^ÖÐ+++++++++++++++++++++++++ËÑË÷(²éÕÒ)±í¸ñÖзûºÏÌõ¼þµÄÐУºFindRowÊôÐÔ£º¸ÃÊôÐÔ·µ»ØÒ»¸öÐÐÖµMsgBoxVSG1.FindRow(¹Ø¼ü´Ê,[Ö¸¶¨ÐÐ],[Ö¸¶¨ÁÐ],[Ãô¸Ð],[¾«¶È])¹Ø¼ü´Ê£ºString£¬±íʾҪËÑË÷µÄ×Ö·û´®Ö¸¶¨ÐÐ/Ö¸¶¨ÁУºLong£¬±íʾֻÔÚÖ¸¶¨µÄÐлòÁÐÖÐÕÒÃô¸Ð£ºBoolean£¬©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥'ÏÞÖÆÖ»ÄÜÔÚÖ¸¶¨ÁÐÊäÈë(ÕâÀïĬÈϵ¹ÊýµÚ2ÁÐ)PrivateSubVSG1_BeforeRowColChange(ByValOldRowAsLong,_ByValOldColAsLong,ByValNewRowAsLong,_ByValNewColAsLong,CancelAsBoolean)VSG1.Editable=fl