DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 05 Aug 2007 17:38:33 -0000,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    unknown


Problem about showing ErrorIcon and Error tooltip text in the dgv.   
Hey all,

I tried to show both error Icon and error tooltrip text when the error
is raised.

The cell ErrorText is set in the CellValidating event handler function
in my dgv like followings,

 if (Convert.ToInt64(e.FormattedValue.ToString()) > 65535)
                            {
                                _cell.ErrorText = "65,535 error!";

                                _cellErrorAppears = true;
                            }

 if (_cellErrorAppears)
                    {
                        if (_cell.Tag == null)
                        {
                            _cell.Tag = _cell.Style.Padding;
                            _cell.Style.Padding = new Padding(0, 0,
25, 0);

                            cellInError = new Point(e.ColumnIndex,
e.RowIndex);
                        }
                        if (errorTooltip == null)
                        {
                            errorTooltip = new ToolTip();
                            errorTooltip.InitialDelay = 0;
                            errorTooltip.ReshowDelay = 0;
                            errorTooltip.Active = false;
                        }

                        e.Cancel = true;

In dgv_CellPainting event handler, the error icon is depicted by the
following,

if (dgv.IsCurrentCellDirty && !String.IsNullOrEmpty(e.ErrorText))
{
                // paint everything except error icon
                e.Paint(e.ClipBounds, DataGridViewPaintParts.All &
                    ~(DataGridViewPaintParts.ErrorIcon));

                // now move error icon over to fill in the padding
space
                GraphicsContainer container =
e.Graphics.BeginContainer();
                e.Graphics.TranslateTransform(18, 0);
                e.Paint(this.ClientRectangle,
DataGridViewPaintParts.ErrorIcon);
                e.Graphics.EndContainer(container);

                e.Handled = true;
}

When the mouse move to the cell, the error tooltrip should show
itself. However, it doesn't. Moreover, when the cell is edited once
more with the wrong input, the error Icon disappear as well.

In dgv_CellMouseMove()
{
if (cellInError.X == e.ColumnIndex &&
                cellInError.Y == e.RowIndex)
            {
                DataGridViewCell _cell = dgv[e.ColumnIndex,
e.RowIndex];

                if (_cell.ErrorText != String.Empty)
                {
                    if (!errorTooltip.Active)
                    {
                        errorTooltip.Show(_cell.ErrorText, dvg, 1000);
                    }
                    errorTooltip.Active = true;
                }
            }
}

In dgv_CellMouseLeave()
{
DataGridViewCell _cell = dgv[e.ColumnIndex, e.RowIndex];

            Font regularFont = new Font(dgv.Font, FontStyle.Regular);
            _cell.Style.Font = regularFont;
}

The code in the CellEndEdit event handler is as follows,

dgv_CellEndEdit()
{

if (dgv[e.ColumnIndex, e.RowIndex].ErrorText != String.Empty)
            {
                DataGridViewCell _cell = dgv[e.ColumnIndex,
e.RowIndex];
                _cell.ErrorText = String.Empty;
                cellInError = new Point(-2, -2);

                _cell.Style.Padding = (Padding)_cell.Tag;

                if (errorTooltip != null)
                {
                    errorTooltip.Hide(dgv);
                    errorTooltip.Dispose();
                    errorTooltip = null;
                }
            }

}

Can anyone give me a hand with this problem?

Thanks in advance.
Date:Sun, 05 Aug 2007 17:38:33 -0000   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us