非經 keyin 的 TInplaceEdit 內容會消失 |
缺席
|
hagar
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
小弟因為 user 需求, 在程式中加入了如 ms-word 的符號表功能
程式碼如下:
procedure TfrmPgm.ToolButton1Click(Sender: TObject); var i: integer; iOldSelStart: integer; ie: TInplaceEdit; sTmp: string; begin if ActiveControl = DBGrid1 then if not (Table1.State in [dsInsert, dsEdit]) then Table1.Edit else Exit; ie := nil; for i := 0 to DBGrid1.ControlCount - 1 do ifDBGrid1.Controls[i] is TInplaceEdit then begin ie := TInplaceEdit(DBGrid1.Controls[i]); Break; end; if Assigned(ie) then begin iOldSelStart := ie.SelStart; sTmp := ie.Text; if ie.SelLength > 0 then // 若有選取部份,先將其刪除 Delete(sTmp, ie.SelStart 1, ie.SelLength); Insert(ToolButton1.Caption, sTmp, ie.SelStart 1); // 插入 ToolButton1 所代表的符號 ie.Text := sTmp; ie.SelStart := iOldSelStart ToolButton1.Caption); end; end;現在在小弟的問題是如果按下 ToolButton1 後 不再由鍵盤加入或刪減 TInplaceEdit 的內容 則 DBGrid1 正在編輯的欄位移動或按下存檔後 原本 Insert 到 TInplaceEdit 的內容並未存到 Table1 的相關欄位內 請教一下大家, 小弟該怎麼解決這麼問題? 謝謝. -- ![]() |
syntax
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
hagar
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
感謝 syntax 大大
是我表達不清
比方說在編輯 DBGrid1 的第 1 個欄位
如此按下 ToolButton1
將 DBGrid1 第 1 個欄位的值插入 ToolButton1 的 Caption
然後游標移至 DBGrid1 的第 2 個欄位
但是剛剛插入第 1 個欄位的 ToolButton1 的 Caption 消失不見
這就是小弟的問題所在
後來小弟在 ie.Text := sTmp; 的這行之前加一行可解決這個現象
DBGrid1.SelectedField.AsString := sTmp; --
![]() |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |