|
In VB.NET 2003, with a listview in large icon view, I need to allow the user to manually rearrange the icons using the mouse. Kind of like a DragDrop operation but not.
I tried all the prop setting for the listview but nada!
A good example would be Windows Explorer in Icons View, set to autoarrange. You can still have them all lined up but you can manually drag and re-arrange the icons.
What do I need to do to set this up?
Thanks for any help.
|
|
|
|
|
The ListView really doesn't have any support for this. In order to have the items rearrangable and allow the user to place the items anywhere they want, you have to have seperate objects for each item in the list and have each item track it's own position on screen. This tracking is not possible using the normal ListViewItem class.
You'd have to come up with your own ListView class and ListViewItem class, possibly extending the standard classes.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That bites If vb6 was able to do it you think vb.net would support it too but in a complicated way, not lie that though
Any other possible way you can think of?
Thanks
|
|
|
|
|
How did you get it to work in VB6?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here is some demo code for VB6. If you drag an item and drop it anywhere in the listview it will move to that position.
Option Explicit<br />
'Add a ListView to your form (ListView1)<br />
Private Sub Form_Load()<br />
Dim i As Integer<br />
With ListView1<br />
.Arrange = lvwAutoTop<br />
.HideSelection = False<br />
.LabelEdit = lvwManual<br />
.MultiSelect = False<br />
.Sorted = False<br />
.View = lvwIcon<br />
For i = 1 To 50<br />
.ListItems.Add , , i<br />
Next<br />
End With<br />
End Sub
|
|
|
|
|
I have a combo box in a VB 6 form that takes its list items from a Database Table.
when i add a new value in that list on the form by clicking on the add button I put an IF check on the add Button.
That IF check is that if the value is present in the list then it gives the msgbox that the value is already present and else it will add the value in the list of that combo box.
the Coding on the Add Button is:
if txtto.text = cboto. then
msgbox "The value is already present"
else
cboto.Additem txtto.text
end if
my problem is that the first part of the IF check doesnt works and by clicking add button it adds the value to the list. What code should I use in that first part of the IF check that it gets right? What property should i use for combo box to make it work correctly?
Its urgent plz help.
|
|
|
|
|
If your getting your combobox data from a database, then see if the item is in the database. If it isn't, add it, then rebind your combobox.
If you want to compare it against the data in the combobox, you'll have to iterate through the entire list of items in it. You can't do just one compare to see if an item is in the list anywhere. You have to compare against each item in the list until you find it or run out of items.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello,
REF: VB6
I'm having trouble setting a variable NAME....
' set these variables
Const pos1 = 100
Const pos2 = 200
Const pos3 = 300
ID_dog = 1
' set variable position_dog
position_dog = "pos" & ID_dog
the result is...
position_dog = "pos1" <===== NOT what I need
I need the result to be a varible like....
position_dog = pos1 <===== I need this
which of course would be equivalent to position_dog = 100
or.....
if I set ID_dog = 2 then position_dog = 200
if I set ID_dog = 3 then position_dog = 300
any ideas ??
thanks in advance!
---- mike
|
|
|
|
|
mike2k5 wrote:
position_dog = "pos1" <===== NOT what I need
I need the result to be a varible like....
position_dog = pos1 <===== I need this
You can't do that. There's no function to evaluate the contents of a string and come up with a variable name reference. An option would be to select the correct constant to assign using a Select statement
SELECT CASE ID_dog
CASE 1
position_dog = pos1
CASE 2
position_dog = pos2
CASE 3
position_dog = pos3
END SELECT
You'll have to provide more details on what your doing if you need a better solution. What is position_dog and how do these constants and ID_dog relate to it? What's the purpose of this code?
|
|
|
|
|
|
hii..
we are doin a MEDIA on DEMAND project..on a client-server system
well.. now we are using Windows 2000 Advanced Server as OS, and i ll be using MSSQL Server as database...
i would like to know whether we can keeb links (path to the files) in the database and the actual files(the audio, video, text doc, PDFs etc.) somewhere else ?? i mean in different directory on the server machine ??
|
|
|
|
|
|
hi, i am making a program with vb.net and I have a problem. Because I want the program to be registered first. I made a form with the register and another one with the program. You first want to register from the register form and then you can use the program form. I made the startup as the program and i used the stream reader to read from a text file if the user registered the program. if the user registered then he can use the program. when he double click the program the second time he (if he registered) i want to show only the program not the registration form of the program because he already registered. How can i make this!! HELP ME PLS!!!
Adrian
|
|
|
|
|
Your registration form should NOT be your startup form. Your main application form should be. The first thing it does should be to check to see of the app is registered, if not, put up the registration form as a modal dialog (ShowDialog). When the registration form is closed, check again to see if the app is registered. What you do from this point on is up to you, but normally you would setup your application in either a "full functionality" mode or a "restricted mode", depending on the registration status.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Q.1) How can you enable/disable network adapters in VB6? Is their a registry setting I can edit or a function that can do this?
Q.2) How can I create a list in a VB project of all Network adapters(NICs) on my PC.
I have done dozens of google and microsoft searches and found nothing but dead ends. I greatly appriciate your help.
Thank you "The Code Project" community
|
|
|
|
|
The reason you didn't find any VB6 code to specifically do this is because, one, it's not something most people would do, and two, they wouldn't normally use VB6 to do it.
1) There is no registry setting that will do this. This must be done by using the Device Manangement API functions. Definately not for the faint of heart, or those weak in COM skills. If you want to take a look at what's involved, click here[^]. You've been warned...
2) You can do this using Windows Management Instrumentation to get a list of Win32_NetworkAdapter s. For more on using WMI, see here[^]. Oh yeah, you cannot use WMI to disable the network adapter(s)!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave,
I'm not sure if I can handel this job on my own, but I've got to get it done somehow so I'll have to learn it. Thanks for your help.
|
|
|
|
|
Oh! BTW, the Device Management functions will only work under an Administrator account...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Option Explicit
Dim Num1 As Variant
Dim Num2 As Variant
Dim Num3 As Variant
Dim Seed As Variant
Dim Answer As Variant
Dim Counter As Variant
Dim Total As Variant
Dim Percent As Variant
Dim Response As Variant
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdNext_Click()
Num1 = 0
Num2 = 0
Num1 = lblNum1 + Num1
Num2 = lblNum2 + Num2
Num3 = Num1 + Num2
TxtResponse = Response
Counter = 0
Total = 0
If (Response <> Num3) Then
lblMessage = ("Wrong")
Total = Total + 1
End If
If (Response = Num3) Then
lblMessage = ("Correct")
Counter = Counter + 1
Total = Total + 1
End If
lblNum1 = Int(Rnd * 11)
lblNum2 = Int(Rnd * 11)
TxtResponse.Text = Format("")
lblScore = ((Counter / Total) * 100)
End Sub
Private Sub Form_Load()
Randomize Seed
Randomize Timer
Num1 = Int(Rnd * 11)
Num2 = Int(Rnd * 11)
lblNum1 = Num1
lblNum2 = Num2
End Sub
----------------------------------------------------
In this code there is an equation using if statements. This equation always evaluates to either true or false. The if statement doesn't alternate depending on the answer that is returned by the user. Is there anyway to get the If statement working propperly?
|
|
|
|
|
Well, you're first problem is that you declared everything as Variant 's. This will only cause you problems since you have no type checking being done on any of your values. Change your Variants to use the correct types. Like Num1, Num2, Num3, should all be Long types.
Next, the if statements you have can, apparently, be combined into one statement. But you never said anything about what this program is supposed to do, so we're just guessing at what you mean by "make it work."
I'd love to rewrite this program from scratch, but it has all the earmarks of homework. But, here's your if statement re-written:
If (Response <> Num3) Then
' if condition is True, execute this block of code,
lblMessage = "Wrong"
Total = Total + 1
Else
' otherwise, execute this block of code.
lblMessage = "Correct"
Counter = Counter + 1
Total = Total + 1
End If
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the help with the long type.
I have tried and tried again incorporating the if statements into one statement. The statement still does not work.
-The program is designed to be a basic flashcard type addition program. Num1 and Num2 are random variables that are to be added together. Num3 is an incorporation of both Num1 and Num2 for ease of programming the if statement.
-The if statement is my big problem i need help with. It always returns a correct. If i change the code around, so the correct is first:
If (Response = Num3) Then
lblMessage="Correct"
Counter = Counter + 1
Total = Total + 1
Else
lblMessage = "Wrong"
Total = Total + 1
End If
The if statement always returns a correct answer and never a wrong one. I am new to VB and am not really sure how to make this work.
|
|
|
|
|
Well, in the interest of teaching, I'll rewrite your entire application. Now, if this is homework, don't even think of trying to turn this in. Your prof WILL KNOW you didn't write it! Especially if your next project gets turned in looking nothing like this one!
Option Explicit
Dim Num1 As Long
Dim Num2 As Long
Dim Total As Long
Dim TotalQuestions As Long
Dim CorrectAnswers As Long
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdNext_Click()
TotalQuestions = TotalQuestions + 1
If CLng(TxtResponse.Text) <> Total Then
lblMessage = "Wrong"
Else
lblMessage = "Correct"
CorrectAnswers = CorrectAnswers + 1
End If
TxtResponse.Text = ""
lblScore = (CorrectAnswers / TotalQuestions) * 100
End Sub
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub GenerateNewTest()
Num1 = int(Rnd * 11)
Num2 = int(Rnd * 11)
Total = Num1 + Num2
lblNum1 = Num1
lblNum2 = Num2
End Sub
This is still nowhere near correct coding practices, but you should get the general idea from this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the Help. I was able to get by program working from part of your code.
|
|
|
|
|
Anyone know where i can get some good help with a CR problem it is pretty advanced stuff.
James Kennelly
|
|
|
|