DevExpress VCL
tcxGrid - Code Snippet to Calculate Distinct Count In Summary Footer
Question - I have a datetime edit set for displaying both the date and the time. But, for a date e.g. 16.02.2007 00:00:00 the time is not displayed, only the date. Inputkind for the control is ikRegExpr kind: ckDateTime What can be done about it?
in procedure TcxCustomDateEditProperties.PrepareDisplayValue, subfunction GetDisplayValue change the end of procedure to : if not NeedShowTime(AValue, AEditFocused) then AValue := DateOf(AValue); Result := DateTimeToTextEx(AValue, True, NeedShowTime(AValue, AEditFocused)); Result := TrimRight(Result); It is not a complete solution but it is a start
Key methods: ViewInfo (painting, and hot tracking): - Assign – assigns all of the ViewInfo fields that can be changed by mouse movement - GetUpdateRegion – returns the editor’s update region – as a result of mouse movement (hot track) - NeedShowHint – inplace mode - Offset – displaces the ViewInfo without calculating (due for release (4.2)) - Paint – paints the editor using ViewInfo data - Repaint – invalidates the editor regions that have been changed as a result of mouse movement* *Grid currently uses the GetUpdateRegion (It will use Repaint in the future). ViewData (calculating ViewInfo, and sizing): - Calculate – calculates ViewInfo - EditValueToDrawValue – converts EditValue into ViewInfo’s internal representation – inplace mode. ViewInfo.Paint draws DisplayValue (text for textedit, state of CheckBox, etc) using this representation. - GetClientExtent – returns the offset of the editor “client area” (for textedit this is the area where text is drawn). - GetEditContentSize – returns the size of the editor area that depends on EditValue - InternalGetEditConstantPartSize - returns the size of editor area that doesn’t depend on EditValue (buttons, icons, checkrect, etc) The editor size is made up of GetEditContentSize and InternalGetEditConstantPartSize – for optimization. Properties: - Assign – all new properties must be assigned - CreateViewData – creates a ViewData instance. - GetContainerClass – the editor’s class - GetDisplayText – text for export, printing, filterdialog - GetEditValueSource – the type of EditValue (string, value, key) – for the grid’s datacontroller, standalone editor’s databinding - GetStyleClass – The style’s class - GetSupportedOperations – which operations a grid column with this Properties accepts - GetViewInfoClass – ViewInfo’s class - IsEditValueValid – if True use PrepareDisplayValue to convert EditValue to DisplayValue; otherwise use the default conversion scheme. - PrepareDisplayValue – converts EditValue to DisplayValue. It is used in some conversion procedures, for example, ViewData.EditValueToDrawValue. Result depends on the editor kind (text for TextEdit, ItemIndex for RadioGroup). - ValidateDisplayValue – performs initial validation of DisplayValue (from editor’s point of view) (before OnValidate will be raised). Edit: - GetPropertiesClass - PrepareEditValue – converts DisplayValue (this depends on the editor kind) into EditValue. - Activate, ActivateByKey, ActivateByMouse – are invoked when an inplace editor is to be activated. - GetDataBindingClass - SynchronizeDisplayValue – sets the editors DisplayValue according to the current EditValue - SynchronizeEditValue – sets the editors EditValue according to the current DisplayValue - ProcessViewInfoChanges – performs actions when the ViewInfo is changed as a result of mouse movement (for example, in TcxCustomEdit ProcessViewInfoChanges invokes DoButtonDown, DoButtonUp, DoButtonClick). - SetSize – adjusts editor size (if AutoSize = True). Override InternalSetDisplayValue, InternalSetEditValue if you want full control over DisplayValue – EditValue assignings. TcxCustomTextEditProperties.GetEditingStyle: - esNoEdit (ButtonEdit.HideCursor = True) - esEdit, esEditList, esFixedList (see TcxComboBoxProperties.DropDownListStyle) Use GetChildControlBounds to manage the InnerEdit window’s region (Windows.SetWindowRgn). If an editor ignores some keys (assigns 0 to Key in DoEditKeyDown) then it must invoke DoAfterKeyDown before this assignment to enable the editor’s container (for example, the grid) to perform its own navigation. Before changing anything in an editor (as a reaction to user activities) check Edit.DataBinding.Modified. If not Edit.DataBinding.Modified then invoke the function DoEditing. It returns false if the editor cannot be changed. CanKeyDownModifyEdit, CanKeyPressModifyEdit Use cxEditUtils.DrawCustomEdit to draw the editor’s borders Registration: resourcestring scxEditRepositoryMyEditItem = 'MyEdit|MyEdit description'; ---------------------------------------------------------------------------- unit MyEdit.pas uses Classes, cxContainer, cxEdit; type TcxEditRepositoryMyEditItem = class(TcxEditRepositoryItem) // see any item in cxEditRepositoryItems.pas end; initialization RegisterClass(TcxEditRepositoryMyEditItem); GetRegisteredEditProperties.Register(TMyEditProperties, scxEditRepositoryMyEditItem); ---------------------------------------------------------------------------- unit MyEditReg.pas uses Classes, cxEditRepositoryEditor, MyEdit; initialization RegisterEditRepositoryItem(TcxEditRepositoryMyEditItem, scxEditRepositoryMyEditItem); finalization UnRegisterEditRepositoryItem(TcxEditRepositoryMyEditItem);
Comments
Post a Comment