ThanksCode:Dim i As Integer
For i = 0 To flds.Length - 1
TreView.Nodes.Add(MyDataset.Tables(0).Columns.Item(i).ToString)
Next
Printable View
ThanksCode:Dim i As Integer
For i = 0 To flds.Length - 1
TreView.Nodes.Add(MyDataset.Tables(0).Columns.Item(i).ToString)
Next
Code:for(int i = 0; i < flds.Lenght - 1; i++)
{
TreView.Nodes.Add(MyDataset.Tables[0].Columns[i].ToString());
}
Thanks DevGrp , I got another one if you can help ...
Code:If TypeOf TxtBox Is TextBox Then
TxtBox.Text = ""
End If
Weird thing ! Why this works (when I add + "") but when I remove it , it won't work and says : Cannot implicitly convert type 'object' to 'string' .anyone can guess !:rolleyes:
this works fine :
but not this :Code:ListVItem = new ListViewItem();
ListVItem.Text = dr["C_URL"]+ "" ;
Thanks .Code:ListVItem = new ListViewItem();
ListVItem.Text = dr["C_URL"] ;
The first one works because the ToString method of dr["C_URL"] is being called behind the scenes when the empty string is appended to the end. To make the one work, you have to explicity call the dr["C_URL"].ToString(). Remember every object implicitly inherits a ToString Method.
Quote:
VB Code:
If TypeOf TxtBox Is TextBox Then TxtBox.Text = "" End If
Code:if(TxtBox is TextBox)
TxtBox.Text = "";
The right hand side will be evaluated before putting the value into the left hand side.
The + "" forces the right hand side to convert.
Why it can't convert implicitly is a mystery. Either they missed it or somebody decided it should work that way.
You can always use the Convert statement if you want t avoid the + "".
Thank you DevGrp .:)
Or call ToString explicitly.
That's what I figured out actually !:D
I tried the codeQuote:
Originally posted by DevGrp
The first one works because the ToString method of dr["C_URL"] is being called behind the scenes when the empty string is appended to the end. To make the one work, you have to explicity call the dr["C_URL"].ToString(). Remember every object implicitly inherits a ToString Method.
Code:if(TxtBox is TextBox)
TxtBox.Text = "";
but it says 'the given expression is always of the provided (Ststem.Windows.Form.TextBox) type. What does that mean?Code:if(TxtBox is TextBox)
TxtBox.Text = "";
That means that TxtBox is of reference type TextBox and therefore can't reference any object where the if clause would be false. Therefore the if is useless.