CGXControl::GetValue

virtual BOOL GetValue(CString& strResult);

strResult

A reference to a CString where the method stores the formatted text.

Return Value

Specifies whether the operation was successful. If it is non-zero, a strResult holds a valid string; if it is FALSE, no value has been copied to strResult.

Remarks

Reads out the window text and converts it into the plain value that should be stored in the style object. Override this method if you have formatted the text displayed in the cell (e.g., convert a formatted date entry into plain information without formatting characters, see the attached example).

The base class version of this method simply returns the value that is displayed in the cell. For example, in an edit control, this is GetWindowText(strResult).

Example

This example demonstrates how you can determine the window text which is displayed in the cell and convert it to the plain information as it should be stored in the style object:

// GetValue
//
// Convert the text that is displayed in the cell to the value
// which should be stored in the style object.
//
// GetWindowText returns for example "01/01/91"
// The resulting text will be "19910101" (as stored in dbase file)
BOOL CDbfDateControl::GetValue(CString& strResult)
{
   // CGXEditControl::GetValue will call GetWindowText()
   if (!CGXEditControl::GetValue(strResult))
      return FALSE;
   // convert strResult into dbase date
   TIMESTAMP_STRUCT ts;
   if (GXParseDateTime(&ts, strResult, gxDEFAULT))
   {
      strResult.Empty();
      wsprintf(strResult.GetBuffer(128), _T("%04d%2d%2d"), ts.year, ts.month, ts.day);
      strResult.ReleaseBuffer();
      return TRUE;
   }
   // failed...
   return FALSE;
}

See Also

 CGXControl::GetControlText

CGXControl

 Class Overview |  Class Members