http://www.fx114.net/qa-29-3439.aspx

回复于: -- ::
unit DBGridEh; 把下面这个函数替换成这样 procedure TDBGridInplaceEdit.WMPaste(var Message: TMessage);
var
ClipboardText: WideString;
FSearchText, AText, tmpText: WideString;
AColumn: TColumnEh;
Idx: Integer;
CanChange, TextLocated, CanTryEdit: Boolean;
EditKeyValue: Variant;
NewSelStart: Integer;
begin
if Grid.AllowedOperationUpdate and Column.CanModify(False) then
if ((EditStyle = esDataList) or (Column.GetColumnType = ctKeyPickList)) then
begin
if Clipboard.HasFormat(CF_TEXT)
then ClipboardText := Clipboard.AsText
else Exit;
with Grid do AColumn := Columns[SelectedIndex];
FSearchText := Copy(Text, , SelStart) + ClipboardText + Copy(Text, SelStart + SelLength + , MAXINT);
CanTryEdit := False;
TextLocated := False;
AText := FSearchText;
if (EditStyle = esDataList) and (AColumn.UsedLookupDataSet <> nil) then //lookup
begin
EditKeyValue := Null;
if AColumn.UsedLookupDataSet.Locate(AColumn.Field.LookupResultField, FSearchText,
[loCaseInsensitive, loPartialKey]) then
begin
AText := AColumn.UsedLookupDataSet.FieldByName(AColumn.Field.LookupResultField).Text;
EditKeyValue := AColumn.UsedLookupDataSet.FieldValues[AColumn.Field.LookupKeyFields];
TextLocated := True;
CanTryEdit := True;
end
else if Assigned(AColumn.OnNotInList) then
CanTryEdit := True; if CanTryEdit then
begin
Grid.DataLink.Edit;
CanChange := Grid.Datalink.Editing;
if CanChange then
begin
Grid.Datalink.Modified;
Text := AText;
SelStart := Length(Text);
if TextLocated
then SelLength := Length(FSearchText) - SelStart
else SelLength := ;
Grid.FEditKeyValue := EditKeyValue;
Grid.FEditText := Text;
if Assigned(FDataList) then FDataList.KeyValue := Grid.FEditKeyValue;
end;
end;
end else //keypicklist
begin
Idx := StringsLocate(AColumn.PickList, FSearchText, [loCaseInsensitive, loPartialKey]);
if (Idx <> -) and Grid.CanEditModifyText then
begin
AText := AColumn.PickList[Idx];
TextLocated := True;
CanTryEdit := True;
end
else if Assigned(AColumn.OnNotInList) then
CanTryEdit := True; if CanTryEdit then
begin
SelStart := Length(AText);
if TextLocated
then SelLength := Length(FSearchText) - SelStart
else SelLength := ; Grid.DataLink.Edit;
CanChange := Grid.Datalink.Editing;
if CanChange then Grid.Datalink.Modified;
Text := AText; Grid.FEditText := Text;
if Assigned(FPickList) then FPickList.ItemIndex := Idx;
end;
end;
end else
begin
if EditCanModify and
( Clipboard.HasFormat(CF_TEXT) or
Clipboard.HasFormat(CF_OEMTEXT) or
Clipboard.HasFormat(CF_UNICODETEXT)
) then
begin
with Grid do AColumn := Columns[SelectedIndex];
ClipboardText := Clipboard.AsText;
AText := AColumn.GetAcceptableEditText(ClipboardText); tmpText := Text;
FSearchText := Copy(tmpText, , SelStart) + AText + Copy(tmpText, SelStart + SelLength + , MAXINT);
NewSelStart := Length(Copy(tmpText, , SelStart) + AText);
Grid.DataLink.Edit;
if Grid.Datalink.Editing then
begin
Grid.Datalink.Modified;
Text := FSearchText;
SelStart := NewSelStart;
Grid.FEditText := Text;
SendMessage(Handle, EM_SCROLLCARET, ,);
end;
end else
inherited;
end;
end;

DBGridEh 在粘贴中文时出现乱码和错位 100zhx_888]的更多相关文章

  1. javascript之url转义escape()、encodeURI()和decodeURI(),ifram父子传参参数有中文时出现乱码

    ifram父子传参参数有中文时出现乱码,可先在父级页面用encodeURI转义,在到子页面用进行decodeURI()解码 我们可以知道:escape()除了 ASCII 字母.数字和特定的符号外,对 ...

  2. php向页面输出中文时出现乱码的解决方法

    今天,刚刚学习PHP发现用echo输出中文时,页面会出现乱码,然后查了一下资料说是浏览器编码格式有问题,要改成utf-8.但是每个人的浏览器编码可能会有所不同,所以找到了一个很好的解决方法, 就是在p ...

  3. C# .net中cookie值为中文时的乱码解决方法

    一.cookie的名称或子cookie的名称不能为中文,否则无法获得cookie 这个好办,名称不用中文即可 二.cookie的值为中文时候,取cookie的值会出现乱码 解决办法:存取cookie时 ...

  4. C#中StreamReader读取中文时出现乱码问题总结

    之前有一篇文章" C#读取及写入配置文件教程"(http://blog.csdn.net/lisenyang/article/details/47291083)当中有一个问题就是在 ...

  5. [文章存档]Azure上部署的java app在向第三方服务传送中文时出现乱码

    https://docs.azure.cn/zh-cn/articles/azure-operations-guide/app-service-web/aog-app-service-web-java ...

  6. JDBC 连接mysql获取中文时的乱码问题

    前段时间学习JDBC,要连接mysql获取数据.按照老师的样例数据,要存一些名字之类的信息,用的都是英文名,我当时就不太想用英文,就把我室友的名字存了进去,嘿嘿,结果,出问题了. 连接数据库语句: s ...

  7. 有效解决ajax传中文时,乱码的情况,php处理接收到的值

    在抽奖环节时,需把获奖名单通过ajax的post方式传输给php后台进行储存,但是php接收到的值确是乱码.在百度之后并没有找到合适的解决方法. 则使用js的encodeURI函数可以有效解决,但不知 ...

  8. Android webView 中loadData方法加载 带中文时出现乱码

    WebView出现乱码用LoadData方法来解析html的,但是据说这是官方的一个BUG,不能用来解析中文. 采用loadDataWithBaseURL的方法,其中codeingType设置为utf ...

  9. 解决中文乱码( jsp表单提交中文时出现乱码)

    有三种方法: 1.建立一个filter中文解决乱码 2.Struts2在struts.xml中修改默认的编码设定 3.用Spring解决中文乱码 4.直接在jsp中修改解决 1.建立一个filter解 ...

随机推荐

  1. 安装PyInstaller打包python

    安装PyInstaller 对于那些网络比较稳定,能够流畅使用pip源地址的用户,直接下面的命令就可以搞定: pip install pyinstaller 通常我们会下载源码包,然后进入包目录,执行 ...

  2. 在CentOS Linux系统上,添加新的端口,启用ssh服务

    SSH作为Linux远程连接重要的方式,如何配置安装linux系统的SSH服务,如何开启SSH? SSH是什么? SSH 为 Secure Shell 由 IETF 的网络工作小组(Network W ...

  3. 第七章 对称加密算法--DES

    注意:本节内容主要参考自<Java加密与解密的艺术(第2版)>第7章“初等加密算法--对称加密算法” 7.1.对称加密算法 特点: 加密与解密使用同一个密钥 是使用最广的算法 常见对称加密 ...

  4. js中的&&和||

    你是否看到过这样的代码:a=a||""; 可能javascript初学者会对此感到茫然.今天就跟大家分享一下我的一些心得. 其实: a=a||"defaultValue& ...

  5. python后端工程师 数据爬虫

    大数据挖掘分析平台和产品的建设. 工作职责: 独立完成软件系统代码的设计与实现: 根据需求完成设计,代码编写,调试,测试和维护: 使用Python 语言对后台业务逻辑进行开发以及维护: 能根据实际需求 ...

  6. LIBS+=

    ZC: “LIBS+=”是要结合“LIBPATH += ”一起使用的?类似下面的用法: ZC: “LIBS+=”指明lib文件的名称,“LIBPATH += ”指明lib文件的路径.最后还要把DLL文 ...

  7. 关于QT的QPainterPath::arcTo 详解

    这个函数文档的意思就是画弧,看了文档也不太明白,自己做了demo终于明白了意思 移动到圆心,画180度半圆 void TestArcTo::paintEvent(QPaintEvent *) { QP ...

  8. 多年未写过java了

    java面试必须了解和记忆的知识点(linux,nginx,数据库之类的暂时不考虑了) java面试的115常见问题,这个博客还是不过的推荐一下吧 http://www.importnew.com/1 ...

  9. Python 爬虫-正则表达式(补)

    2017-08-08 18:37:29 一.Python中正则表达式使用原生字符串的几点说明 原生字符串和普通字符串的不同 相较于普通字符串,原生字符串中的\就是反斜杠,并不表达转义.不过,字符串转成 ...

  10. 浅触selinux(持续更新)

    ls -lZ 查看selinux权限情况 chcon命令 修改对象(文件)的安全上下文,比如:用户.角色.类型.安全级别.也就是将每个文件的安全环境变更至指定环境.使用--reference选项时,把 ...