...

View Full Version : convert this code in C#



handshakeit
03-08-2006, 12:30 PM
Hi all

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


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

s4sadia
02-14-2007, 09:10 AM
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;
}
}

s4sadia
02-14-2007, 09:33 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum