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. React 回忆录(四)React 中的状态管理

    Hi 各位,欢迎来到 React 回忆录!

  2. Python3基础 input 输入浮点数,整数,字符串

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. HDU 1171 Big Event in HDU(0-1背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=1171 题意:给出一系列的价值,需要平分,并且尽量接近. 思路:0—1背包问题. 0-1背包问题也就是有n种物品且 ...

  4. 关于express项目的创建与启动

    没有经常用,所以经常搞错, 创建express项目,需要新建一个文件夹名,这个文件名就是用来承载express的内容的, 好了.打开终端,cd至创建的文件夹之下. 也可以直接这样,如以下,admin为 ...

  5. Cocos2d-x学习笔记(四) HelloWorld场景类

    类定义原型如下: #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" ...

  6. sudo: unable to resolve host myhostname: Connection timed out

    第一种 原因,/etc/hostname 中的hostname 与/etc/hosts 里面的不对应,导致无法解析 将两个文件的hostname改成一样的即可. /etc/hostname aaa / ...

  7. Python day15装饰器基本理论,以及结合全局变量模拟session

    装饰器(decorator):为其他函数添加附加功能 原则:1.不修改被修饰函数源代码 2.不修改被修饰函数的调用方式 装饰器=高阶函数+函数嵌套+闭包 import time def timmer( ...

  8. java数组声明和变式--record1

    ​ java声明数组方式: String[] namelist; int numlist[];//此声明为动态声明,不能指定长度,numlist[10] 静态声明的方式: int a[]={1,2,3 ...

  9. 算法笔记--字符串hash

    概述: 主要用于字符串的匹配. 定义hash函数: H(c)=(c1bm-1 +c2bm-2 +...+cmb0)mod h 对于字符串c中l-r区间的hash值: H(l,r)=H(1,r)-H(1 ...

  10. Codeforces 496D - Tennis Game

    496D - Tennis Game 思路:枚举每个t,求出对应的满足条件的s. 代码: #include<bits/stdc++.h> using namespace std; #def ...