Home Forums WinForms controls Xceed Grid for WinForms Cell value changed event

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14723 |

    I want to validate values entered in the cells. As I tried by following codes, i could not get it done.

    Private Sub fillGrid
    grdProduct.DataSource = prodDs.Tables(0)
    Dim cell As Xceed.Grid.DataCell
    For Each cell In grdProduct.DataRowTemplate.Cells
    AddHandler cell.ValueChanged, AddressOf cell_ValueChanged
    Next cell
    End Sub

    Private Sub cell_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    MsgBox(“changed”)
    End Sub

    Any suggestions why above code not raising the event ??

    Imported from legacy forums. Posted by PETE (had 3992 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to do it on the CellEditorManager, and the implementation will depend on the editor that is used for the cell / column.
    <i>
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    </i>
    //do it before filling the data to the gird <i>
    AddHandler GridControl2.Columns( 1 ).CellEditorManager.ActivatingControl, AddressOf CellEditorManager_ActivatingControl
    AddHandler GridControl2.Columns( 1 ).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_DeactivatingControl

    End Sub

    Private Sub CellEditorManager_ActivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )
    </i>
    //The cast must correspond to the editor set as the CellEditorManager, by default a WinTextBox for string columns<i>
    Dim editor as Xceed.Editors.WinTextBox = CType( e.Control, Xceed.Editors.WinTextBox)
    AddHandler editor.TextBoxArea.KeyDown, AddressOf editor_KeyDown

    End Sub

    Private Sub CellEditorManager_DeactivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )

    Dim editor as Xceed.Editors.WinTextBox = CType( e.Control, Xceed.Editors.WinTextBox)
    RemoveHandler editor.TextBoxArea.KeyDown, AddressOf editor_KeyDown

    End Sub

    Private sub editor_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs )
    </i>
    ‘Your keydown event code here
    <i>
    End Sub
    </i>

    Imported from legacy forums. Posted by André (had 299 views)

    User (Old forums)
    Member
    Post count: 23064

    That works fine. I can play around more than what i expected.

    Is it possible to get the original value of cell (wintextbox), after editied ?

    Imported from legacy forums. Posted by PETE (had 503 views)

    User (Old forums)
    Member
    Post count: 23064

    You can revert back to the cell’s original value as long as the EndEdit has not committed the changes to the cell, by using the EndingEdit event. You can look at the following topics from the online help documentation, to have a better idea on cell validation, and the different options you have :

    http://doc.xceedsoft.com/products/gridNET/doc/sources/validating.htm
    http://doc.xceedsoft.com/products/gridNET/doc/sources/validation_process.htm

    There is also a sample application that demonstrate how to validate the content of a grid:

    Master directory:
    [Program Files]\Xceed Components\Xceed Grid for .NET [version]\Samples\VS.NET 2003
    or
    [Program Files]\Xceed Components\Xceed Grid for .NET [version]\Samples\VS.NET 2005

    C#: \CSharp\Validating\ValidatingCS.csproj
    VB.NET: \Visual Basic .NET\Validating\ValidatingVB.vbproj

    Imported from legacy forums. Posted by André (had 4256 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.