Click here to Skip to main content
15,920,053 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalstoreing encrypted passwords Pin
AAGTHosting9-Feb-08 14:10
AAGTHosting9-Feb-08 14:10 
GeneralRe: storeing encrypted passwords Pin
Thomas Stockwell9-Feb-08 15:12
professionalThomas Stockwell9-Feb-08 15:12 
GeneralRe: storeing encrypted passwords Pin
Guffa9-Feb-08 16:12
Guffa9-Feb-08 16:12 
GeneralError creating window handle. Pin
Rupesh Kumar Swami9-Feb-08 3:21
Rupesh Kumar Swami9-Feb-08 3:21 
GeneralRe: Error creating window handle. Pin
Dave Kreskowiak11-Feb-08 4:27
mveDave Kreskowiak11-Feb-08 4:27 
QuestionAn intrique question about Splitcontainer! Pin
JUNEYT9-Feb-08 2:38
JUNEYT9-Feb-08 2:38 
QuestionHow to collect the links in a WebBrowser Document ? [modified] Pin
SekharOne9-Feb-08 0:07
SekharOne9-Feb-08 0:07 
QuestionWhat is causing invalid index when use listviewitemcomparer? Pin
JUNEYT9-Feb-08 0:03
JUNEYT9-Feb-08 0:03 
Hi!

I have a listview box within 2 columns. When I populate and sort the listviewbox with ListviewItemComparer, I don't get any error but when I do it second time inside from another procedure ,I have received invalid index of 1 message in ListviewItemComparer class file. In second time When I apply an index of 0 for the column to sort, I don't get any error message but when I define 2nd column in listview box, I get error.

Any help will be appreciated!
Thanks.

Juneyt.


<br />
    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
        Call LoadTags()<br />
    End Sub<br />

<br />
<br />
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click<br />
<br />
   'I reload it when any new entry takes a place in database<br />
<br />
    Call LoadTags()<br />
<br />
    End Sub<br />



<br />
Private Sub LoadTags()<br />
<br />
        Dim mySelectQuery As String = "SELECT * FROM Tags"<br />
        Dim myconnection As New OleDbConnection(SQLConnStr)<br />
        Dim myCommand As New OleDbCommand(mySelectQuery, myconnection)<br />
<br />
        myconnection.Open()<br />
<br />
        Dim myReader As OleDbDataReader = myCommand.ExecuteReader<br />
<br />
        If myReader.HasRows = False Then<br />
            myReader.Close()<br />
            myconnection.Close()<br />
            Exit Sub<br />
        End If<br />
<br />
        ListView1.Items.Clear()<br />
<br />
        While myReader.Read<br />
<br />
            ListView1.Items.Add(myReader.GetValue(0).ToString)<br />
            Dim TACC As Int32 = ListView1.Items.Count - 1<br />
<br />
            ListView1.Items(TACC).SubItems.Add(Trim(myReader.GetValue(1).ToString))<br />
<br />
        End While<br />
<br />
        myReader.Close()<br />
        myconnection.Close()<br />
<br />
<br />
        If ListView1.Items.Count > 1 Then<br />
           'The error occurs here!<br />
            ListView1.ListViewItemSorter = New ListViewItemComparer(1)<br />
            ListView1.Sort()<br />
        End If<br />
<br />


<br />
Public Class ListViewItemComparer<br />
    Implements IComparer<br />
    Private col As Integer<br />
<br />
    Public Sub New()<br />
        col = 0<br />
    End Sub<br />
<br />
    Public Sub New(ByVal column As Integer)<br />
        col = column<br />
    End Sub<br />
<br />
    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _<br />
                            Implements System.Collections.IComparer.Compare<br />
        Dim returnVal As Integer = -1<br />
        returnVal = [String].Compare(CType(x, _<br />
                        ListViewItem).SubItems(col).Text, _<br />
                        CType(y, ListViewItem).SubItems(col).Text)<br />
        Return returnVal<br />
    End Function<br />
<br />
<br />
End Class<br />



What a curious mind needs to discover knowledge is noting else than a pin-hole.


GeneralRe: What is causing invalid index when use listviewitemcomparer? Pin
Dave Kreskowiak11-Feb-08 4:21
mveDave Kreskowiak11-Feb-08 4:21 
GeneralSelect item in combobox when index is known Pin
nishkarsh_k8-Feb-08 23:10
nishkarsh_k8-Feb-08 23:10 
GeneralRe: Select item in combobox when index is known Pin
Thomas Stockwell9-Feb-08 3:00
professionalThomas Stockwell9-Feb-08 3:00 
QuestionReporting issue Pin
Tauseef A8-Feb-08 22:35
Tauseef A8-Feb-08 22:35 
GeneralRe: Reporting issue Pin
Dave Kreskowiak11-Feb-08 4:12
mveDave Kreskowiak11-Feb-08 4:12 
Generalconnecting via LAN Pin
revath8-Feb-08 20:43
revath8-Feb-08 20:43 
GeneralRe: connecting via LAN Pin
nishkarsh_k8-Feb-08 22:52
nishkarsh_k8-Feb-08 22:52 
GeneralRe: connecting via LAN Pin
Dave Kreskowiak11-Feb-08 4:09
mveDave Kreskowiak11-Feb-08 4:09 
GeneralOpening x64 registry using a 32-bit program Pin
Techguy8-Feb-08 20:03
Techguy8-Feb-08 20:03 
GeneralRe: Opening x64 registry using a 32-bit program Pin
Techguy10-Feb-08 15:12
Techguy10-Feb-08 15:12 
GeneralRe: Opening x64 registry using a 32-bit program Pin
Dave Kreskowiak11-Feb-08 4:07
mveDave Kreskowiak11-Feb-08 4:07 
GeneralRe: Opening x64 registry using a 32-bit program Pin
Techguy11-Feb-08 11:05
Techguy11-Feb-08 11:05 
GeneralAuto-Click on run Pin
Prower8-Feb-08 16:52
Prower8-Feb-08 16:52 
GeneralRe: Auto-Click on run Pin
nishkarsh_k8-Feb-08 18:03
nishkarsh_k8-Feb-08 18:03 
GeneralRe: Auto-Click on run [modified] Pin
Prower9-Feb-08 12:12
Prower9-Feb-08 12:12 
GeneralRe: Auto-Click on run Pin
Dave Kreskowiak11-Feb-08 3:59
mveDave Kreskowiak11-Feb-08 3:59 
Generaldatagrid as a data entry Pin
alzaabi20xx8-Feb-08 11:59
alzaabi20xx8-Feb-08 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.