DBGridEh 在粘贴中文时出现乱码和错位 100zhx_888]
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]的更多相关文章
- javascript之url转义escape()、encodeURI()和decodeURI(),ifram父子传参参数有中文时出现乱码
ifram父子传参参数有中文时出现乱码,可先在父级页面用encodeURI转义,在到子页面用进行decodeURI()解码 我们可以知道:escape()除了 ASCII 字母.数字和特定的符号外,对 ...
- php向页面输出中文时出现乱码的解决方法
今天,刚刚学习PHP发现用echo输出中文时,页面会出现乱码,然后查了一下资料说是浏览器编码格式有问题,要改成utf-8.但是每个人的浏览器编码可能会有所不同,所以找到了一个很好的解决方法, 就是在p ...
- C# .net中cookie值为中文时的乱码解决方法
一.cookie的名称或子cookie的名称不能为中文,否则无法获得cookie 这个好办,名称不用中文即可 二.cookie的值为中文时候,取cookie的值会出现乱码 解决办法:存取cookie时 ...
- C#中StreamReader读取中文时出现乱码问题总结
之前有一篇文章" C#读取及写入配置文件教程"(http://blog.csdn.net/lisenyang/article/details/47291083)当中有一个问题就是在 ...
- [文章存档]Azure上部署的java app在向第三方服务传送中文时出现乱码
https://docs.azure.cn/zh-cn/articles/azure-operations-guide/app-service-web/aog-app-service-web-java ...
- JDBC 连接mysql获取中文时的乱码问题
前段时间学习JDBC,要连接mysql获取数据.按照老师的样例数据,要存一些名字之类的信息,用的都是英文名,我当时就不太想用英文,就把我室友的名字存了进去,嘿嘿,结果,出问题了. 连接数据库语句: s ...
- 有效解决ajax传中文时,乱码的情况,php处理接收到的值
在抽奖环节时,需把获奖名单通过ajax的post方式传输给php后台进行储存,但是php接收到的值确是乱码.在百度之后并没有找到合适的解决方法. 则使用js的encodeURI函数可以有效解决,但不知 ...
- Android webView 中loadData方法加载 带中文时出现乱码
WebView出现乱码用LoadData方法来解析html的,但是据说这是官方的一个BUG,不能用来解析中文. 采用loadDataWithBaseURL的方法,其中codeingType设置为utf ...
- 解决中文乱码( jsp表单提交中文时出现乱码)
有三种方法: 1.建立一个filter中文解决乱码 2.Struts2在struts.xml中修改默认的编码设定 3.用Spring解决中文乱码 4.直接在jsp中修改解决 1.建立一个filter解 ...
随机推荐
- cent os下搭建简单的服务器
作为常和网络打交道的程序员,经常会遇到需要服务器的场合,比如搭建一个web服务器,一个代理服务器,又或者一个小型的游戏服务器. 我时常和朋友一起玩一款叫我的世界的游戏,为了能够长期稳定地联机玩,所以特 ...
- 【Coursera】Technology :Fifth Week(2)
The Ethernet Story Bob Metcalfe Bob 参与了 Xerox 研究项目,着手解决建造一个处处连接个人计算机的架构.当时,他们刚刚完成了 Internet 的开端 -具有 ...
- 51nod 1199 Money out of Thin Air(线段树+树剖分)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1199 题意: 思路:因为是一棵树,所以需要把它剖分一下再映射到线段树上, ...
- hdu 1427 速算24点 dfs暴力搜索
速算24点 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem De ...
- python flask demo
from flask import Flask, jsonify from flask import abort from flask import make_response from flask ...
- jquery zTree异步加载的例子
下面是使用zTree异步加载的一个例子: 1)初始化树的时候是ajax请求,返回nodes列表来初始化树的:如果一开始就异步的话,$.fn.zTree.init($("#zTree" ...
- Qt5_Oracle
1.编译驱动: 1.1.源码路径:F:\ZC_software_installDir\Qt5.3.2_vs2010\5.3\Src\qtbase\src\plugins\sqldrivers\ 里面有 ...
- 【Golang】Debug :decoding dwarf section info at offset 0x0: too short
解决方法 通过下面的方式升级dlv 来解决这个问题: go get -u github.com/derekparker/delve/cmd/dlv 下面是我记录的定位问题的过程 问题描述 博主升级到了 ...
- idea忽略文件
- Unity 4.x 资源加载
using UnityEngine; using System.Collections; using System.IO; public class LoadResource : MonoBehavi ...