|
Visual Studio has nothing to do with this. The limits of the controls are imposed by the control libraries in Windows and .NET.
Why on earth would you put a million items in a ListBox, or any other control for that matter? It'll take forever to populate unless you use "virtual mode", and, as a user, would you want to navigate through all that? Of course not! So why would ever do this?
|
|
|
|
|
@Dave Kreskowiak, Why on earth would you not want to know the actual limits on controls? Microsoft has wrongly stated constraints in the past and it would take forever to find out if they were right or wrong if no one ever tested them. Wrong about the virtual mode. It did not take forever to populate. It was fast. Why assume that virtual mode would be the default avenue of effort? Of course I did not use virtual mode. That would have been a waste of time. Is that how you personally would do testing? Why would you even think of using virtual mode? Is that how you think? Are you so boxed into virtual mode that you assume it?
Why would you never test the limits of Visual Studio?
How would a mechanical engineer know the strain hardening within the stress/strain curve (Young's modulus) of various materials if no one ever tested such?
How would an aeronautical engineer know the travel of the shock-fit across the surface of a supersonic Joukowsky airfoil at various speeds if no one ever tested it?
How would an electrical engineer know that at ultra-high voltage the electrons leave the man-made electrical conducter and follow a plasmatic cloud self-created by those electrons if no one ever tested it?
Think before you answer! At least think before you answer me.
To test, of course. An Aeronautical, or Civil, or Electrical, or Electronic, or Mechanical, or Structural engineer would know that. I would guess that even a Systems Engineer would do testing, but I may be wrong.
I did not ask for your opinion on Visual Studio. I asked who noticed this capacity. You did not even answer the question. You went on a tangent.
Please allow people that, "noticed this capacity" to answer the question.
|
|
|
|
|
I never said testing the limits of the controls was irrelevant. Those are technical limits. Using the controls is subject to the usability limits of users. Sure, you can put a million items in a listbox. Now what?
Putting a million items in a control is putting your users through navigation hell. Are you seriously going to expect users to search through that many items to find the one, or more, they want? If you don't code for the limits of your users, they uninstall your app.
Technical limits are only one aspect of the "limits" you should be concerned about.
|
|
|
|
|
@Dave Kreskowiak, your wisdom about focusing on users I accept.
I explained in a different reply (to Gerry Schmitz) in this thread why I wanted the sort and what I had discovered.
The list and the sort would not necessarily be for the user to see, but for my internal use. And, by using a list box sort I did not have to include a sort of my own in code and could keep the final file size smaller. Microsoft has some very nice code already written that behind the scenes does some amazing things fast. I used their years of experience and army of coders to speed up my program and lessen the final size of it.
But, I was still left with the question of "How did they do that?" So, now I am attempting to devour C and C++ as fast and as thoroughly as I can. Read, study, code, try not to pull out hair, ask here, repeat.
Thank you.
|
|
|
|
|
Member 15078716 wrote: Who else has noticed this capacity? I have never had a need to put that many in. The limits on most similar controls is usually available memory, so if you can get that many in it merely proves what good job Microsoft did in creating the control.
Member 15078716 wrote: Does the latest version of Visual Studio have this capacity for it's listbox? This has nothing to do with Visual Studio. A ListBox is a Windows control.
|
|
|
|
|
@Richard MacCutchan, I bow to your wisdom.
Much of what I have done in programming after I retired has been based upon studing your postings.
Maybe it is a holdover from my working days, but I still occationally test what I am working with.
Thank you.
|
|
|
|
|
You didn't put it "in a listbox"; you created a collection with a million entries; entries which could be anything. A "listbox" is a "visual"; it "simulates" what you think you see; it's not "real"; the collection is what's "real".
You have a collection that consumes memory based on the size of the entries; that's it. And at some point, once a collection is big enough, the system starts "paging"; and if there is not enough memory, it starts thrashing. That's where the performance, or lack thereof, comes in.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
@Gerry Schmitz, I had wondered if that was the case, when I did the test.
I had wondered, while using Visual Studio (almost exclusively) for programming, if I could code a sort routine that was as fast as the listbox sort was. I was wanting the ability to sort a large amount of data without using a pre-built database. I was also attempting to keep my executable file to a minimum size, while being able to use it on a Windows computer that did not have VS installed. I tested some and liked the listbox sort. I accidently input beyond what I was told the listbox could hold, and it still sorted correctly, and fast. So, somewhere the limit was not actually the limit. Thus, I tested, with increasing amounts until I found that a listbox could be used by me as a sorting process with over one million entries. Search for a sort that is as fast as a listbox for my vast entries was over.
I call it a listbox, but I know that there is no box and it is all some binary switching via Insulated Gate Bypolar Transistors.
Thank you for sharing your wisdom. I hope to have learned from it.
Or, could that be trinary switching since the insulated gate is simply an updated switch from the days of previous transistor designs. Or, could it be quadnary switching since ... So much to ask. Maybe a different question for that. Maybe a phD in semi-conductor circuit design electronic component engineering would know that.
Thank you.
|
|
|
|
|
The listbox doesn't "sort" either; that's the job of the collection. You think it's sorting because that's where the interface is. The person in the drive-thru window doesn't actually make the burger; someone else does and passes it back.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
@Gerry Schmitz, very nice analogy.
|
|
|
|
|
Fantastic analogy actually. I'm stealing it!
|
|
|
|
|
|
Thank you Thank you Thank you. Your answer is so valid.
<list> looks good. But I was just wondering if someone had noticed the VS ListBox capacity was way beyond advertised.
I do not use Visual Studio or Visual Basic or Visual Java at this time. I do not program with .NET at this time. I do not use DirectX in my programming at this time.
I am retired and I am attempting to learn C and C++ without the help of those helpers. I do not even use boost. I am trying to become a real C and C++ programmer.
Thank you for your offer of a solution. It looks like what I might have used before I retired. It looks like solid code. But, even though I thank you I can not use it.
Thank you.
|
|
|
|
|
Then have a look at std::list - cppreference.com
It has nothing to do with .NET.
It has nothing to do with Visual Studio.
It is standard container in C++.
|
|
|
|
|
Thank you. Your wisdom is appreciated.
|
|
|
|
|
For i = 0 To .DataGridView1.Rows.Count - 1
cn.Open()
cm = New MySqlCommand("update tblproduct set qty = qty - " & CInt(.DataGridView1.Rows(i).Cells(9).Value.ToString) & " where id like '" & .DataGridView1.Rows(i).Cells(1).Value.ToString & "'", cn)
cm.ExecuteNonQuery()
cn.Close()
|
|
|
|
|
... abd does it work?
|
|
|
|
|
Victor Nijegorodov wrote: ... abd does it work?
Not as written. Even if the logic is correct (and we have no way of ascertaining what is in cols 1 and 9) OP needs a Next statement.
Also, why is the value to be subtracted converted to a String and then parsed to CInt only for it to be boxed (a Javaism) / wrappered (JSism) back to a String?
And, can the OP confirm that the ID is a string (hence the quotes)? It is common for it to be a sequential number.
|
|
|
|
|
jsc42 wrote: why is the value to be subtracted converted to a String and then parsed to CInt only for it to be boxed (a Javaism) / wrappered (JSism) back to a String? That sequence is more and more common these days. I can only assume they are learning it from YouTube.
|
|
|
|
|
|
Hello everyone
subject is declare event on Form1 , and run that event on Form2
here is the code , but event doesnt work on Form2 !! what is missing here??
many thanks
Public Class Form1
Private Sub btnOpenForm2_Click(sender As Object, e As EventArgs) Handles btnOpenForm2.Click
Form2.Show()
End Sub
Public Event show_My_Message()
Private Sub btnShowMessageOnForm2_Click(sender As Object, e As EventArgs) Handles btnShowMessageOnForm2.Click
RaiseEvent show_My_Message()
End Sub
End Class
Public Class Form2
Public WithEvents My_Form1 As Form1 = New Form1
Private Sub Show_My_Message_On_Form2() Handles My_Form1.show_My_Message
MsgBox("Hello")
End Sub
End Class
|
|
|
|
|
What you're doing seems backwards, but, hey, it's your app and I don't know anything about it.
Since Form2 doesn't (and SHOULDN'T!) know anything about Form1. By doing this, you forever tie both forms together making it impossible to use one of them without the other.
Your Form2 code is creating a NEW INSTANCE of Form1, NOT using the existing instance! That's why it doesn't work. You do not need the "WithEvents", or even that entire line, on Form2.
If Form2 needs to subscribe to events exposed by Form1, you have to pass your instance of Form1 to a constructor on Form2 so it knows which instance events to subscribe to. Then the constructor needs to "wire-up" the event handlers for whatever events it needs, manually using AddHandler.
My VB.NET is really rusty, so the following may not even compile let alone run:
Public Class Form1
Public Event Show_My_Message(ByVal message As String)
Private Sub btnOpenForm2_Click(sender As Object, e As EventArgs) Handles btnOpenForm2.Click
Dim form2 As New Form2(Me)
form2.Show()
End Sub
Private Sub btnShowMessageOnForm2_Click(sender As Object, e As EventArgs) Handles btnShowMessageOnForm2.Click
RaiseEvent Show_My_Message("Some message")
End Sub
End Class
Public Class Form2
Public Sub New(Form1 eventProvider)
AddHandler eventProvider.Show_My_Message, AddressOf ShowMyMessageHandler
End Sub
Public Sub ShowMyMessageHandler(ByVal message As String)
MsgBox(message)
End Sub
End Class
|
|
|
|
|
I've never got along with Events - they seem overly convoluted for simple tasks. My (also) rusty VB suggests that something like the following might do what you want (it is probably overkill)
Public Class Form1
Private f2 As Form2 = Nothing
Sub F2IsActive(Enabled As Boolean)
btnStartForm2.Enabled = Not Enabled
btnDoSomethingOnForm2.Enabled = Enabled
btnCloseForm2.Enabled = Enabled
If Enabled Then
If Not FormIsOpen(f2) Then
f2 = New Form2()
f2.Show()
End If
ElseIf FormIsOpen(f2) Then
f2.Close()
f2 = Nothing
End If
End Sub
Private Sub btnStartForm2_Click(sender As Object, e As EventArgs) Handles btnStartForm2.Click
F2IsActive(True)
End Sub
Private Sub btnDoSomethingOnForm2_Click(sender As Object, e As EventArgs) Handles btnDoSomethingOnForm2.Click
If f2 Is Nothing Then
MsgBox("You have to open Form2 first")
ElseIf FormIsOpen(f2) Then
f2.DoSomethingOnForm2()
Else
MsgBox("Form2 has disappeared")
F2IsActive(False)
End If
End Sub
Private Function FormIsOpen(formToFind As Form) As Boolean
For Each testform As Form In Application.OpenForms
If testform.Equals(formToFind) Then
Return True
End If
Next
Return False
End Function
Private Sub btnCloseForm2_Click(sender As Object, e As EventArgs) Handles btnCloseForm2.Click
If Not FormIsOpen(f2) Then
MsgBox("Form2 has already been closed")
End If
F2IsActive(False)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
F2IsActive(False)
End Sub
End Class
Public Class Form2
Public Sub DoSomethingOnForm2()
MsgBox("Hello from Form 1")
End Sub
End Class
modified 6-Jul-22 12:42pm.
|
|
|
|
|
Hi Everyone,
I hope I'm posting this in the right place. I'm using VistaDb version 6.2 I have a Main Database with several tables Like Clients, Inventory, etc. I have a Backup Database with the same table(s) and structure as the Main database. I'm trying to copy 1 or more records from the Backup Database, like the Inventory Table to the Main Database Inventory Table. The code below is inserting records from the Main database inventory table, and not from the backup database. Do I need to do this by First selecting the data and placing it in a tmp table then insert the records from the tmp table? Any help would be appreciated.
Here is the code I have:
Private Sub TransferInventory()
Dim MyFile As String = TreeListTransfer.FocusedNode(0).ToString
Dim VdbConn1 As String = "Data Source=" & Application.StartupPath & "\Backup\" & MyFile & ".vdb6"
Try
For i As Integer = 0 To LstFiles.Items.Count - 1
LstFiles.SelectedIndex = i
FileId = CInt(LstFiles.Text)
Using conn As New VistaDBConnection(VdbConn)
conn.Open()
StrSql = "INSERT INTO Inventory(ClientId, Category, Product, PartNo, PurchaseDate, Unit, UnitPrice, InStock, OnOrder, Photo)
SELECT ClientId, Category, Product, PartNo, PurchaseDate, Unit, UnitPrice, InStock, OnOrder, Photo
FROM dbo.Inventory
WHERE (InventoryId = @InventoryId)"
Using cmd As New VistaDBCommand(StrSql, conn)
With cmd.Parameters
.AddWithValue("@InventoryId", FileId)
End With
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
Next
MessageBox.Show("Transfer successfully completed on the 'Inventory' table", "Transfer Inventory Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Transfer Inventory Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
Finally
End Try
End Sub
Thanks in Advance.
|
|
|
|
|
|