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. Django组件(三) Django之中间件

    中间件概述 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用,用不好会影响到性 ...

  2. P1600 天天爱跑步

    lca真心不太会,这里只介绍60分做法,100的太难辣简单了就不介绍了 n<=1000 zz回溯爆搜 S[i]全部相等 这dfs序都不用lca的,2333,差分,然后输出判断一下是否是0(1到i ...

  3. 第十四章 数字签名算法--RSA

    注意:本节内容主要参考自 <Java加密与解密的艺术(第2版)>第9章“带密钥的消息摘要算法--数字签名算法” <大型分布式网站架构(设计与实践)>第3章“互联网安全架构” 1 ...

  4. 安卓开发 UI入门

    布局的类型 线性布局 LinearLayout ***  垂直显示 vertical 水平显示 horizontal 文本适应 wrap_content 填充父窗体 match_parent 权重 l ...

  5. animate动画回调函数

    对非动画的实现排队,比如这个css()是要放在回调函数里才能,让前面的动画执行完成后在进行实现 $('button').click(function(event) { $(this).next().a ...

  6. DBMS 数据库管理系统 DataBase Management System

  7. POJ 3667 Hotel(线段树+区间合并)

    http://poj.org/problem?id=3667 题意: 有N个房间,M次操作.有两种操作(1)"1a",表示找到连续的长度为a的空房间,如果有多解,优先左边的,即表示 ...

  8. 翻译header

    !/usr/bin/env pyhton --coding:utf-8-- import urllib.request import urllib.parse import os,sys import ...

  9. hdu 5144 NPY and shot 物理+三分

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  10. python写入csv文件的几种方法总结

    生成test.csv文件 #coding=utf- import pandas as pd #任意的多组列表 a = [,,] b = [,,] #字典中的key值即为csv中列名 dataframe ...