Results 1 to 2 of 2

Thread: How to prevent cursor skips from one cell to another in VB.net datagrid?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    1

    How to prevent cursor skips from one cell to another in VB.net datagrid?

    Hi all,

    I have designed a datagrid in VB.net to show,modify,add and delete records from a table. Now I want to validate user's input before the cursor skips to next cell or next row. If validation fails, the cursor should stay where it was. I tried table's columnChanging/RowChanging event. But I couldn't find how to prevent the cursor from jumping to next cell or row. Could anyone help?

    thx.

  2. #2
    New Member Fishey's Avatar
    Join Date
    Mar 2006
    Posts
    1

    DataGrid Data validation and messages

    Hi There
    I have a similar problem
    I have datagrids that I am using, that has not been specified with databinding from the datagrid properties.
    See the code below.....

    My pain is that I need to generate messages for data entry errors, for
    1. Compulsory Columns
    2. Range Checks

    Can anyone help PLEASE?


    VB Code:
    1. Private Sub CreateGrid()
    2.         Dim tsSeats As New DataGridTableStyle
    3.         tsSeats.MappingName = "Seats"
    4.         Dim dtSeats As DataTable = DsSeats1.Tables("Seats")
    5.         Dim i As Integer
    6.  
    7.         While i < dtSeats.Columns.Count
    8.  
    9.             Dim txtCol As New DataGridTextBoxColumn
    10.             With txtCol
    11.                 .MappingName = dtSeats.Columns(i).ColumnName
    12.                 .HeaderText = dtSeats.Columns(i).ColumnName
    13.  
    14.                 If i = 0 Then
    15.                     .Width = 70
    16.                     .ReadOnly = True
    17.                 Else
    18.                     .Width = 100
    19.                 End If
    20.                 tsSeats.GridColumnStyles.Add(txtCol)
    21.             End With
    22.  
    23.  
    24.             i = i + 1
    25.  
    26.         End While
    27.         dgSeats.TableStyles.Clear()
    28.         dgSeats.TableStyles.Add(tsSeats)
    29.         dgSeats.DataSource = dtSeats
    30.     End Sub
    Fishey
    Visual Basic.Net 2003

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width