Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Mon, 6 Mar 2006 06:01:40 -0800,    group: microsoft.public.dotnet.datatools        back       


DataGridView: Operand in a column   
Suppose I have a DataGridView (VS 2005) (called myDataGridView) which is 
bound to a MS Access DataBase, one of the columns is a percentage, it’s 
defined as a ‘double’ field in the Access side, as to the DataGridView side, 
the column was created using the folowing formatting (I skipped column 
naming, data binding and other irrelevant formattings):

Dim myColumn As new DataGridViewColumn
myColumn.DefaultCellStyle.Format = "P"
myDataGridView.Columns.Add(myColumn)

The column is displayed just fine, all the cells are displayed as ’25 %’, 
with an underlying data value of ‘0,25’.

I want to give the user the possibility of having a percentage operator, so 
the user types percentages as ’25 %’, and they are converted to 0,25 when 
parsing the cell in the CellParsing event handler. 

So, I wrote the CellParsing event handler like:

Private Sub myDataGridView_CellParsing(ByVal sender As Object, ByVal e As 
System.Windows.Forms.DataGridViewCellParsingEventArgs) Handles 
myDataGridView.CellParsing
    Select Case Me. myDataGridView.Columns(e.ColumnIndex).Name
      Case "fldRefunds"
'e.value must be something like 25% (and not 2%5), since 
'it was already validated in the cellValidating event 
'handler 
        If CStr(e.Value).Contains("%") Then
          e.Value = CStr(e.Value).Replace("%", "").Trim
          e.Value = CStr(CDbl(e.Value) / 100)
          e.ParsingApplied = True
        End If
    End Select 'Select Case Me.DataGridView1...
  End Sub 'myDataGridView_CellParsing

According to my understanding, it should work, but it doesn’t. It produces a 
dataError event with a context of 768: DataGridViewDataErrorContexts(Commit + 
Parsing).

What am I doing wrong or missing?

Can anybody help me with it?

------------------------

Thanks in advance

Other_Developer_More
date: Mon, 6 Mar 2006 06:01:40 -0800   author:   Other_Developer_More

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us