Your code works fine if I do as below. This creates two columns called "A" and "B" with "1" and "Second Item" in the first row. Is this what you intended?
Code:
ListView1.View = View.Details
ListView1.Columns.Add("A")
ListView1.Columns.Add("B")
Dim Row As Integer = 1
Dim MyItem = ListView1.Items.Add(Row)
With MyItem
.SubItems.Add("Second Item")
End With
Bulldog thanks for your reply but don't resolve my problem with this code
I make Columns with Edit Columns in design mode and set properties of View to Details, too
other idea
It semms you are transfering from vb6 to .Net. You need to set the "Option explicit and option strict" properties ON in your VS. Or you need to have these two lines on top of your code
vb Code:
Option Explicit On
Option Strict On
copy them as it is shown than you will see why it doesn't work.
vb Code:
Option Explicit On
Option Strict On
Public Class Form1
End Class
Rating is a way of saying thank you. Don't forget to rate always!
If you have the "Option Explicit On" and "Option Strict On" on top of your class then the parts that are not correct in your code should be underlined. If you move the mouse on top of them then it will tell you what is wrong.
Rating is a way of saying thank you. Don't forget to rate always!
If CheckBox1.Checked = True Then
Select Case SeaType
Case "allname"
TSQL = "SELECT * FROM hd WHERE fname LIKE '" & LLike & TextBox3.Text & RLike & "' AND lname LIKE '" & LLike & TextBox2.Text & RLike & "'"
Case "status"
If RadioButton5.Checked = True Then TSQL = "SELECT * FROM hd WHERE status ='inact'"
If RadioButton6.Checked = True Then TSQL = "SELECT * FROM hd WHERE status ='act'"
Case "cost"
TSQL = "SELECT * FROM hd WHERE cost " & Opera & " '" & TextBox5.Text & "'"
Case "allcost"
TSQL = "SELECT * FROM hd WHERE allcost " & Opera & " '" & TextBox5.Text & "'"
Case "fname"
TSQL = "SELECT * FROM hd WHERE fname LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "lname"
TSQL = "SELECT * FROM hd WHERE lname LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "uname"
TSQL = "SELECT * FROM hd WHERE uname LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "coname"
TSQL = "SELECT * FROM hd WHERE coname LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "tel"
TSQL = "SELECT * FROM hd WHERE tel LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "mob"
TSQL = "SELECT * FROM hd WHERE mob LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "address"
TSQL = "SELECT * FROM hd WHERE address LIKE '" & LLike & TextBox4.Text & RLike & "'"
Case "email"
TSQL = "SELECT * FROM hd WHERE email LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "domain"
TSQL = "SELECT * FROM hd WHERE [domain] LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "host"
TSQL = "SELECT * FROM hd WHERE host LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "panel"
TSQL = "SELECT * FROM hd WHERE panel LIKE '" & LLike & TextBox1.Text & RLike & "'"
Case "info"
TSQL = "SELECT * FROM hd WHERE info LIKE '" & LLike & TextBox4.Text & RLike & "'"
Case "khost"
TSQL = "SELECT * FROM hd WHERE khost LIKE '" & LLike & ComboBox2.Text & RLike & "'"
Case "time"
TSQL = "SELECT * FROM hd WHERE time LIKE '" & LLike & Numeric.Value & RLike & "' AND KDuration='" & Duration & "'"
Case "bdate"
TSQL = "SELECT * FROM hd WHERE bdate LIKE '" & LLike & MTextBox1.Text & RLike & "'"
Case "edate"
TSQL = "SELECT * FROM hd WHERE edate LIKE '" & LLike & MTextBox1.Text & RLike & "'"
End Select
con.Open()
cmd.CommandText = TSQL
cmd.Connection = con
data = cmd.ExecuteReader
Do While data.Read
If data("Panel") <> "nothing" Then
Pnl = data.Item("Panel")
Else
Pnl = "-----"
End If
If data("status") = "act" Then
Sta = "فعال"
ElseIf data("status") = "inact" Then
Sta = "غيرفعال"
End If
Dim MyItem As New ListViewItem
Name = data("Fname") & " " & data("Lname")
MyItem = ListView1.Items.Add(Row)
With MyItem
.SubItems.Add("هاست و دامين")
.SubItems.Add(data("uname"))
.SubItems.Add(Name)
.SubItems.Add(data("Coname"))
.SubItems.Add(data("tel"))
.SubItems.Add(data("Mob"))
.SubItems.Add(data("Email"))
.SubItems.Add(data("address"))
.SubItems.Add(data("domain"))
.SubItems.Add(data("host"))
.SubItems.Add(data("BandW"))
.SubItems.Add(data("khost"))
.SubItems.Add(Pnl)
.SubItems.Add(data("cost"))
.SubItems.Add(data("allcost"))
.SubItems.Add(data("bdate"))
.SubItems.Add(data("time") & " " & ComboBox4.Text)
.SubItems.Add(data("edate"))
.SubItems.Add(Sta)
.SubItems.Add(data("info"))
End With
Row += 1
Loop
con.Close()
End If
Shamsoft, I thought we went through this but it seems you didn’t understand it. What is the “Row”? It is an integer! Does “ListView1.Items.Add” method except integer type parameter? No!
So why and how come you have it there? You said that you have the “Option Strict” set to On so how come you don’t see that it is underlined?
Rating is a way of saying thank you. Don't forget to rate always!
What is the “Row”? It is an integer! Does “ListView1.Items.Add” method except integer type parameter? No!
yeah. is integer. it mean i cannot using integer value in this parameter?
You said that you have the “Option Strict” set to On so how come you don’t see that it is underlined?
no. I don't use Option Explicit On & Option Strict On. because i don't use this Option for my codes but they have not any error message. for example i don't use Option Explicit On & Option Strict On in AllD.vb and also using ListView. but it have not any error
yeah. is integer. it mean i cannot using integer value in this parameter?
No you cant. You need to take a look what types the method excepts as a parameter.
no. I don't use Option Explicit On & Option Strict On. because i don't use this Option for my codes but they have not any error message. for example i don't use Option Explicit On & Option Strict On in AllD.vb and also using ListView. but it have not any error
I don't know why you don't use Option Explicit On & Option Strict On in your projects but it is a good way of notifing about the errors. My guess is that you don't use it becuse you have non latin letters in your code. But you still can use it and ignore some errors while you are coding. And when you want to run the project than just comment them out.
Rating is a way of saying thank you. Don't forget to rate always!
No you cant. You need to take a look what types the method excepts as a parameter.
ok. thanks a lot. My problem Resolved
I don't know why you don't use Option Explicit On & Option Strict On in your projects but it is a good way of notifing about the errors. My guess is that you don't use it becuse you have non latin letters in your code. But you still can use it and ignore some errors while you are coding. And when you want to run the project than just comment them out.
yeah. i must be use the Option Explicit On & Option Strict On in my project. because i programming by vb6 in last (and now) and i beginner in vb.net, i don't habit to use Option Explicit On & Option Strict On in my project. but i try to using this.
thanks to your helps again
Just a tip, you can set these options for your Visual Studion so that you don't need to have these lines on top of each class. To set it in vs you need to do:
Click on Tools menu button and select "Options" menu item. Expend the "Projects and Solution" node and select "VB Defaults" and set the options to On at the right.
Last edited by VBDT; Jul 28th, 2007 at 06:50 PM.
Rating is a way of saying thank you. Don't forget to rate always!