Go Back   Wiki NewForum > Career Forum (Documents/Tutorials/Advice) > Tech Forum & Tutorial > IT Forum

Reply
Views: 1048 Source: CNN18.com, India-Forums, TellyChakkar, India, Times of India, Youtube, BollywoodLife, Rediff  
Thread Tools Rate Thread Display Modes
  #6  
Old 06-01-2009, 04:59 PM
bholus7 bholus7 is offline
Banned
 
Join Date:
Apr 2009
Posts: 1,322
Default

Formatting for Display
Anytime the grid needs to know ďhow would this cell displayĒ
it needs to get its FormattedValue. This is a complex
routine because formatting something on the screen usually
needs to be converted to a string.

For example, although you
set a cellís value to the integer value of 155 when 155
needs to be displayed it has to become formatted for the
display.

The cells and columnís FormattedValueType property
determines the type that is used for display. Most columns
use string, but the image and check box cells\columns have
different values. The DataGridViewImageCell and column use
Image as the default FormattedValueType since its painting
code knows how to display an image.

A checkbox cell\columnís
FormattedValueType varies depending upon the value of
ThreeState. At the cell level, all of this is controlled via
the DataGridViewCell::GetFormattedValue(...) method.

By default, the DataGridView uses TypeConverters to convert
a cellís value to its formatted value. Retrieving the proper
TypeConverter is based upon the cellís ValueType and
FormattedValueType properties.

For a cell, the FormattedValue is requested many times.
Anytime the cell is painted or when a column needs to be
autosized based upon the cellís content; the FormattedValue
is even needed when determining if the mouse is over the
cell content or not.

Anytime the FormattedValue is required
the DataGridView raises the CellFormatting event. This
provides you with the opportunity to modify how the cell is
formatted.

If a cell cannot retrieve its formatted value correctly it
raises the DataError event.
Part of formatting a cell for display is understanding what
the preferred size of the cell is.

The preferred size is a
combination of the cellís FormattedValue, any padding or
additional display and the borders.


Painting the Display
After the FormattedValue is retrieved the cellís responsible
for painting the cellís content. The cell determines the
correct style to paint with (see the Styling section later
in this document) and paints the cell.

It is important to
note that if a cell does not paint itself then nothing is
painted. A row or column performs no painting, so ensure
that at least a background is painted in the cell otherwise
the rectangle remains invalidated (unpainted).
Ads
Reply With Quote
Reply

New topics in IT Forum

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump


All times are GMT. The time now is 03:39 PM.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2017, vBulletin Solutions, Inc.