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解 ...
随机推荐
- 史丰收速算|2014年蓝桥杯B组题解析第四题-fishers
史丰收速算 史丰收速算法的革命性贡献是:从高位算起,预测进位.不需要九九表,彻底颠覆了传统手算! 速算的核心基础是:1位数乘以多位数的乘法. 其中,乘以7是最复杂的,就以它为例. 因为,1/7 是个循 ...
- BZOJ4419: [Shoi2013]发微博 暴力
Description 刚开通的SH微博共有n个用户(1..n标号),在短短一个月的时间内,用户们活动频繁,共有m条按时间顺序的记录: ! x 表示用户x发了一条微博: + x y 表示用户x和用 ...
- Nginx 负载均衡的几种方式
如果Nginx没有仅仅只能代理一台服务器的话,那它也不可能像今天这么火,Nginx可以配置代理多台服务器,当一台服务器宕机之后,仍能保持系统可用.具体配置过程如下: 1. 在http节点下,添加ups ...
- java中年月日的加减法,年月的加减法使用
本文为博主原创,未经允许不得转载: java计算两个年月日之间相差的天数: public static int daysBetween(String smdate,String bdate) thro ...
- org.apache.jasper.JasperException: /WEB-INF/view/../../../common/common1.jsp (line: 7, column: 1) Page directive must not have multiple occurrences of pageencoding
本文为博主原创,未经允许,不得转载: 先还原错误: org.apache.jasper.JasperException: /WEB-INF/view/../../../../common/common ...
- 【Coursera】Security Introduction -Ninth Week(1)
前言 Coursera 的 Internet History,Technology,and Security 进入最后一周的学习了,在这最后一周内,需要进行的内容是 public-key 公钥系统的讲 ...
- NOI 4977 怪盗基德的滑翔翼(LIS)
http://noi.openjudge.cn/ch0206/4977/ 描述: 怪盗基德是一个充满传奇色彩的怪盗,专门以珠宝为目标的超级盗窃犯.而他最为突出的地方,就是他每次都能逃脱中村警部的重重围 ...
- 正则表达式及R字符串处理之终结版
http://yphuang.github.io/blog/2016/03/15/regular-expression-and-strings-processing-in-R/ 0.动机:为什么学习字 ...
- shell 基本操作小结
1.echo和if else fi命令 #!/bin/bash echo hello;echo there filename=demo.sh if [ -e "$filename" ...
- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
sudo apt-get install libsdl-dev或 sudo apt-get install libsdl1.2-dev