We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,548 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

problem in listview

Private Sub cmdOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOut.Click
      If txtempno.Text = String.Empty Then
          MsgBox("Insert first your employee number.", vbExclamation)
          lblIN.Text = ""
          lblOUT.Text = ""
          Exit Sub
      End If

      Dim ssql As String

      ssql = "UPDATE tbl_timerec SET TimeOUT=@lblOUT WHERE EmpNo=@txtempno"
      Dim com As New SqlCeCommand
      Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
          Try
              lblOUT.Text = lbltime.Text
              With com
                  con.Open()
                  com.CommandType = CommandType.Text
                  com.CommandText = ssql
                  com.Connection = con
                  com.Parameters.AddWithValue("@lblOUT", lblOUT.Text)
                  com.Parameters.AddWithValue("@txtempno", txtempno.Text)
              End With
          Catch ex As Exception
              MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
          Finally
              com.ExecuteNonQuery()
              Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
              lv.SubItems.Add(lblOUT.Text)
              MsgBox("Successfully Logged OUT!", vbInformation, "Success!")
              lblIN.Text = ""
              lblOUT.Text = ""
          End Try
      End Using
  End Sub

My problem is when i click log out. it goes to the next row of the listview at the column of Timeout.. here's some picture :-/

http://dl.dropbox.com/u/58701482/problem1.PNG

3
Contributors
13
Replies
6 Hours
Discussion Span
1 Year Ago
Last Updated
14
Views
bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

can you please explain your prob , so that i can help you

M.Waqas Aslam
Master Poster
762 posts since Aug 2011
Reputation Points: 58
Solved Threads: 126
Skill Endorsements: 2

can you please explain your prob , so that i can help you

check the picture. the problem is when i click the button 'TIME OUT' it will go to the newline of the listview. I want is. just like this.. check the picture of the buttom.

EmpNo. TIME IN. TIME OUT.
123 8:00am 9:00pm


http://dl.dropbox.com/u/58701482/problem1.PNG

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

At the risk of sounding overly picky, in your first post you said "click log out", and in your next post you said "click the button 'TIME OUT'". Note that in neither picture do you have a button labeled as "log out" or "TIME OUT". It helps to be precise.

In any case, have you tried just resizing the column so that the text doesn't wrap? Because the text "OUT" already appears in the column header, why not just remove it from the output? You don't include "IN" with the time in data, why include "OUT" with the time out data?

Reverend Jim
Illigitimae non carborundum
Moderator
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33

At the risk of sounding overly picky, in your first post you said "click log out", and in your next post you said "click the button 'TIME OUT'". Note that in neither picture do you have a button labeled as "log out" or "TIME OUT". It helps to be precise.

In any case, have you tried just resizing the column so that the text doesn't wrap? Because the text "OUT" already appears in the column header, why not just remove it from the output? You don't include "IN" with the time in data, why include "OUT" with the time out data?

Sorry. the button is

CLOCK IN AND CLOCK OUT.. i just want to replace the 'OUT' string in that. Did you see the picture? and the red arrow?

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

No prob. It was easy to see what you meant but it may not on a more complicated example. Did you try removing the "OUT" text or resizing the column?

Reverend Jim
Illigitimae non carborundum
Moderator
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33

No prob. It was easy to see what you meant but it may not on a more complicated example. Did you try removing the "OUT" text or resizing the column?

i tried and test and tried.. but there is always a blank or 'OUT' word. my problem only is on my list view but in my database is okay.

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I can't tell the value of lblOUT.Text by the picture. I presume by the time you took the picture, lblOUT.Text had been blanked, but somewhere you are setting it to "OUT" plus a date/time. Either change this assignment or remove "OUT" before adding it to the listview, perhaps like

lv.SubItems.Add(lblOUT.Text.Substring(4))

or

lv.SubItems.Add(lblOUT.Text.Replace("OUT ", ""))

Reverend Jim
Illigitimae non carborundum
Moderator
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33

I can't tell the value of lblOUT.Text by the picture. I presume by the time you took the picture, lblOUT.Text had been blanked, but somewhere you are setting it to "OUT" plus a date/time. Either change this assignment or remove "OUT" before adding it to the listview, perhaps like

lv.SubItems.Add(lblOUT.Text.Substring(4))

or

lv.SubItems.Add(lblOUT.Text.Replace("OUT ", ""))

sorry both them didn't work...

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

Reverend Jim
Illigitimae non carborundum
Moderator
3,743 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

it says 'OUT' in all that codes.

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

Imports System.Data.SqlServerCe
Public Class DTR
    Private Sub tmrclock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrclock.Tick
        lbltime.Text = TimeOfDay()
        lbldate.Text = Date.Now().ToString("D")
    End Sub
    Private Sub cmdIN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdIN.Click
        If txtempno.Text = "" Then
            MsgBox("Insert first your employee number.", vbExclamation)
            Exit Sub
        End If
        If lblIN.Text = "" Then
            MsgBox("ASD")
            Exit Sub
        End If

        Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
            Dim com As New SqlCeCommand("INSERT INTO tbl_timerec (EmpNo,TimeIN) values(@txtempno,@lblIN)", con)
            Try
                lblIN.Text = lbltime.Text
                With con
                    con.Open()
                    com.Parameters.AddWithValue("@lblIN", lblIN.Text)
                    com.Parameters.AddWithValue("@txtempno", txtempno.Text)
                    com.ExecuteNonQuery()
                End With
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
            Finally
                con.Close()
                Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
                MsgBox("Successfully Logged In!", vbInformation, "Success!")
                lblIN.Text = ""
                lblOUT.Text = ""
            End Try
        End Using
    End Sub

    Private Sub cmdOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOut.Click
        If txtempno.Text = String.Empty Then
            MsgBox("Insert first your employee number.", vbExclamation)
            lblIN.Text = ""
            lblOUT.Text = ""
            Exit Sub
        End If

        Dim ssql As String

        ssql = "UPDATE tbl_timerec SET TimeOUT=@lblOUT WHERE EmpNo=@txtempno"
        Dim com As New SqlCeCommand
        Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
            Try
                lblOUT.Text = lbltime.Text
                With com
                    con.Open()
                    com.CommandType = CommandType.Text
                    com.CommandText = ssql
                    com.Connection = con
                    com.Parameters.AddWithValue("@lblOUT", lblOUT.Text)
                    com.Parameters.AddWithValue("@txtempno", txtempno.Text)
                End With
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
            Finally
                com.ExecuteNonQuery()
                Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
                lv.SubItems.Add(lblOUT.Text.Replace("ASD", ""))
                MsgBox("Successfully Logged OUT!", vbInformation, "Success!")
                lblIN.Text = ""
                lblOUT.Text = ""
            End Try
        End Using
    End Sub
End Class

this is all my code.

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

it says 'OUT' in all that codes.

anyone? please? help..

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

anyone? Please? Help..

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

bry090911
Newbie Poster
18 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.1131 seconds using 2.71MB