Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    convert this code in C#

    Hi all

    Can Any one convert this in C#
    I hav problem in CBool function what it does

    Code:
    Private afterCurrentCellChanged As Boolean = False
    Private Sub dataGrid1_Click(ByVal sender As System.Object, _
           ByVal e As System.EventArgs) Handles DataGrid1.Click
       Dim discontinuedColumn As Integer = 0
       Dim pt As Point = Me.dataGrid1.PointToClient( _
           Control.MousePosition)
       Dim hti As DataGrid.HitTestInfo = _
           Me.dataGrid1.HitTest(pt)
       Dim bmb As BindingManagerBase = _
           Me.BindingContext(Me.dataGrid1.DataSource, _
           Me.dataGrid1.DataMember)
    
       If afterCurrentCellChanged _
          AndAlso hti.Row < bmb.Count _
          AndAlso hti.Type = DataGrid.HitTestType.Cell _
          AndAlso hti.Column = discontinuedColumn Then
            Me.DataGrid1(hti.Row, discontinuedColumn) = _
               Not CBool(Me.DataGrid1(hti.Row, _
                     discontinuedColumn))
        End If
        afterCurrentCellChanged = False
    End Sub 'dataGrid1_Click
    
        'add a line to this existing handler
    Private Sub dataGrid1_CurrentCellChanged( _
                ByVal sender As System.Object, _
                ByVal e As System.EventArgs) _
            Handles DataGrid1.CurrentCellChanged
        'if click on a discontinued row, then set 
        'currentcell to checkbox
        Dim discontinuedColumn As Integer = 0
        Dim val As Object = Me.DataGrid1( _
             Me.DataGrid1.CurrentRowIndex, _
             discontinuedColumn)
        Dim productDiscontinued As Boolean = CBool(val)
        If productDiscontinued Then
             Me.DataGrid1.CurrentCell = _
               New DataGridCell( Me.DataGrid1.CurrentRowIndex, _
                                 discontinuedColumn)
        End If
        'add this line
        afterCurrentCellChanged = True 
    End Sub 'dataGrid1_CurrentCellChanged

  • #2
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code In C#

    Code:
    private void dg_AL_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    //dg_Al is DataGrid1//////////////////////
    DataGrid g  = dg_AL;
    DataGrid.HitTestInfo hti = g.HitTest(new Point(e.X, e.Y));
    BindingManagerBase bmb = BindingContext[g.DataSource, g.DataMember];
    if((hti.Row < bmb.Count) && (hti.Type == DataGrid.HitTestType.Cell) && hti.Row !=hitRow)
    { 
    if(!(toolTip1 == null) && toolTip1.Active)
    {
    toolTip1.Active = false;
    }
    string tipText = "";
    if (Convert.ToBoolean(dg_AL[hti.Row, 0]))
    {
    tipText = dg_AL[hti.Row, 1].ToString()+" discontinued";
    if(tipText != "")
    {
    //	new hit row
    hitRow = hti.Row;
    toolTip1.SetToolTip(dg_AL, tipText);
    // make it active so it can show
    toolTip1.Active = true ;
    }
    else
    { hitRow = -1;}
    }
    else
    hitRow = -1;
    }
    }

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cbool is for boolean colum in datagrid which is mapped by bool column of product table from northwind database .complete list of coding is available at

    http://msdn2.microsoft.com/en-us/library/ms996485.aspx

    and CBool is function that is chking for 0 and 1 value and converting it n true and false


  •  

    Posting Permissions

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