{"id":268,"date":"2008-05-09T21:04:07","date_gmt":"2008-05-09T21:04:07","guid":{"rendered":"http:\/\/6teen.ru\/?p=16"},"modified":"2008-05-09T21:04:07","modified_gmt":"2008-05-09T21:04:07","slug":"6391","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=268","title":{"rendered":"DBGrid &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430"},"content":{"rendered":"<p>DBGrid &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>DBGrid - \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430\n\n\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 dbgrid \u0432 clipboard\n\u043c\u043e\u0436\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430 \u0432\u044b\u0431\u043e\u0440\u043e\u043a\n\u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0438:\n\nunit ungridtoclb;\n\ninterface\n\nuses\nwindows, sysutils, classes, dialogs, grids, dbgrids, db, dbtables, clipbrd;\n\nprocedure copygrdtoclb(dbg :tdbgrid);\n\/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 dbgrid \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442\u0441\u044f\n\/\/ \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440, \u0442\u0430\u043a \u0438 \u0432 excel\n\nimplementation\n\nprocedure copygrdtoclb(dbg: tdbgrid);\nvar\nbm: tbookmark;\npch, pch1: pchar;\ns, s2: string;\ni, j: integer;\nbegin\ns := '';\nfor j := 0 to dbg.columns.count - 1 do\ns := s + dbg.columns.items[j].title.caption +#9 ;\ns := s + #13 + #10;\nif not dbg.datasource.dataset.active then begin\nshowmessage('\u041d\u0435\u0442 \u0432\u044b\u0431\u043e\u0440\u043a\u0438!!!');\nexit;\nend;\ntry\ndbg.visible := false; \/\/ \u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0445\u043e\u0434\u0438\u043b\u043e \u0432\u0440\u0435\u043c\u044f\n\/\/ \u043d\u0430 \u0435\u0435 \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u043f\u0440\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0435 dataset\nbm := dbg.datasource.dataset.getbookmark; \/\/ \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c\ndbg.datasource.dataset.first;\nwhile not dbg.datasource.dataset.eof do begin\ns2 := '';\nfor j := 0 to dbg.columns.count - 1 do begin\ns2 := s2 + dbg.columns.items[j].field.asstring + #9;\nend;\ns := s + s2 + #13 + #10;\ndbg.datasource.dataset.next;\nend;\n\/\/ \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \" \u0432 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u0440\u0435\u0436\u0438\u043c\" , \u0438\u043d\u0430\u0447\u0435 - \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u043e\u0439\ngetmem(pch, 100);\ngetmem(pch1, 100);\ngetkeyboardlayoutname(pch);\nstrcopy(pch1, pch);\nwhile pch < > '00000419' do begin\nactivatekeyboardlayout(hkl_next, 0);\ngetkeyboardlayoutname(pch);\nif strcomp(pch, pch1) = 0 then\n\/\/ \u041a\u0440\u0443\u0433 \u0437\u0430\u043c\u043a\u043d\u0443\u043b\u0441\u044f - \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 '00000419'\nstrcopy(pch, '00000419');\nend;\nclipboard.astext := s; \/\/ \u0414\u0430\u043d\u043d\u044b\u0435 - \u0432 \u0431\u0443\u0444\u0435\u0440!!!\nwhile strcomp(pch, pch1) < > 0 do begin \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b\nactivatekeyboardlayout(hkl_next, 0);\ngetkeyboardlayoutname(pch);\nend;\nfreemem(pch);\nfreemem(pch1);\ndbg.datasource.dataset.gotobookmark(bm);\n\/\/ showmessage('\u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430.');\nfinally\ndbg.visible := true;\nend;\nend;\n\nend.\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DBGrid &#8212; \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[401,386],"tags":[1906,626,253,862],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/268"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/268\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}