//輸入事件中將字母設置爲大寫 if Key in ['a'..'z'] then begin Key := UpperCase(key)[1]; end;
//DBGrid排序方法 procedure TForm1.DBGridEh1TitleBtnClick(Sender: TObject; ACol: Integer; Column: TColumnEh); begin if (pos('▲', Column.Title.Caption)=0) and (pos('▼', Column.Title.Caption)=0) then //說明前面沒有排過序 begin qryQuery.Sort := Column.FieldName+ ' ASC'; //asc必定要大寫 Column.Title.Caption := column.Title.Caption + '▼' ; end else if (pos('▲', Column.Title.Caption)=0) then //說明目前是降序 begin qryQuery.Sort := Column.FieldName+' ASC'; // ↑佔用了1個位 Column.Title.Caption := copy(Column.Title.Caption,1,length(Column.Title.Caption)-1) + '▲'; end else if (pos('▼', Column.Title.Caption)=0) then //說明目前是升序 begin qryQuery.Sort := Column.FieldName+' DESC'; Column.Title.Caption := copy(Column.Title.Caption,1,length(Column.Title.Caption)-1) + '▼'; end; { if Column.Title.SortMarker = smdowneh then begin qryQuery.Sort:=Column.FieldName + ' DESC'; end else begin qryQuery.Sort:=Column.FieldName +' ASC'; end; } end;