hi,

i have problem here....if listview reach 2 records i disable the addmore button but when i delete 1 transaction from the list view it suppose enable the addmore button. Is there anyway i can do that. please guide me

you can always use a dataset / datatable, fill it, use a select query to return all the records, count the rows returned, if it's over a certain number then btn.visible = true ?

- Jordan

hi,

the code below is to disable the addmore button when it reaches 2 record. How do i make if 1 record is deleted and i have to enable the addmore button. I use the below code but it doesnt seems working. disable button working perfectly but i don't know how to enable the button back if user deleted 1 of the record in listview. Please guide me !!!

if listview1.items.count < 2 then
           AddMoreBtn.Enabled = true
           end if
If ListView1.Items.Count = 2 Then
            AddMoreBtn.Enabled = False
            frmPopup.lblErrMsg.Text = GetButtonText("only 2 record allowded")
            frmPopup.YesNo = False
            frmPopup.QorEx = False
            frmPopup.ShowDialog()
            Exit Sub
               End If

hi,

i don't get you actually. Can you explain how was it base on my code.

Well the code would be

ListView1.DataBind()

Basically refreshes the ListView with the current data, so if you've just deleted, you would databind the ListView to show the record has gone and only 1 now exists.

- Jordan

hi,

i'm sorry. i'm totally new to vb.net. where should i add the code on my code. If you don't mine please modify it on my codes. PLEASE !!!!

Just before your If statements, ListView1.DataBind()

Which means it will always have the latest data available to it

- Jordan

hi,

ok as your guidance i code like this but it gives error "databind is not member of system.window.forms.listview". PLEASE HELP ME !!!

ListView1.DataBind()
        If ListView1.Items.Count < 2 Then
            Panel1.Enabled = True
        End If

ohhh i forgot you're probably doing a Windows app, i'm a web developer! ¬_¬

sorry!

- Jordan

You don't have to disable your add button just use if ...else statement some thing like this

if listview1.items.count < 2 then
' your code for adding record in listview1
else

messagebox.show("List view is full")

endif

Best Of Luck

This question has already been answered. Start a new discussion instead.