|
Well, it would all depend on when you are going to insert the item. Personally, I would give the user a button to press when they want to insert a selected user. Then you could just do this:-
ListView1.Items.Add(ComboBox1.SelectedItem)
in the click event handler.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Unfortunately No
The problem is that in Listview are 4 Cols
So nr (the first one)
Name (where combobox will place the data)
Thanks in advance
|
|
|
|
|
I think you should explain more clearly how you want the end result.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
in the form i have a combobox and 2 textboxes and 2 command buttons cmd 1 (insert) cmd 2 (Delete)
under them is placed one listview
Now,i have configured in loading form and everytime that forms load in the combobox are displayed some names
when you select one name and click insert,this name displayed on listview.after this you can add another name to the field and so on.
the name that you insert is displayed in col2 because col1 is dedicated to ordinal numbers (depending on how rows are in lisview.)
|
|
|
|
|
Then try something like this:-
Dim lvi As ListViewItem = New ListViewItem()
lvi.SubItems.Add(ComboBox1.SelectedItem)
ListView1.Items.Add(lvi)
That will give you the users name in the second column.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Still the same problem.seems that doesn't work
|
|
|
|
|
Well, I suggest you use the link provided by MicroVirus to learn the basics of the ListView . Then you should be able to work it out yourself.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
What you do is you add a ListViewItem via ListView.Items.Add, and store the returned ListViewItem object. Then, you can use this object to add subitems via ListViewItem.SubItems.Add.
See, for instance, MSDN ListView sample[^]
|
|
|
|
|
Maybe it's better to use ms flexgrid.but i don't know how to save flexgrid in my ms acess database.
|
|
|
|
|
Hi,
I have a public function that generates a CRC32 checksum of a file. What I am looking to add to it is a progress bar that progresses as the checksum is created.
CRC32 Function
Public Function GetCrc32(ByRef stream As System.IO.Stream) As Integer
Dim crc32Result As Integer
crc32Result = &HFFFFFFFF
Dim buffer(BUFFER_SIZE) As Byte
Dim readSize As Integer = BUFFER_SIZE
Dim count As Integer = stream.Read(buffer, 0, readSize)
Dim i As Integer
Dim iLookup As Integer
Dim tot As Integer = 0
Do While (count > 0)
For i = 0 To count - 1
iLookup = (crc32Result And &HFF) Xor buffer(i)
crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And &HFFFFFF
crc32Result = crc32Result Xor crc32Table(iLookup)
Next i
count = stream.Read(buffer, 0, readSize)
Loop
GetCrc32 = Not (crc32Result)
End Function
the function is then called when I click on a button
Dim f As FileStream = New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
crc = c32.GetCrc32(f)
lblCRC32.Text = Hex(crc)
How do I add a progress bar to work with the function and display the actual progress.
Thanks
J
|
|
|
|
|
What you do is you get the file length (stream.Length ) and then you divide the current amount of bytes processed by this value. If you multiply this fraction by 100 then you get the percent complete.
All you have to do then is add a progress bar to your form, set its Min to 0, Max to 100, at the start of GetCrc32 set its Value to 0 and then after every iteration you set the progressbar Value to the percent you calculated.
On a final note: you might want to do this calculating and updating the progress bar only every N iterations rather than each to avoid slowing down the function, where N is some reasonable value, like 512 or 1024 (after half and 1 KiB reads respectively).
|
|
|
|
|
Thank you for your answer but how do I know how many bytes are processed
|
|
|
|
|
Edit: sorry ignore last response, didn't read the question properly......
Anyway, You know the file length from the Stream.length as per the previous message.
You also know how my bytes are being read on each iteration on the buffer.
You add a totaliser, and with each byte read create the total read so far, then its simply: (total read so far / total length) * 100
|
|
|
|
|
DaveAuld is correct. Also, the stream.Position gives how many bytes you've read in this case.
|
|
|
|
|
Cool. Thanks guys for the help
|
|
|
|
|
I have a MDB that has 600000 records(more or less). When I'm getting data from that MDB it takes time to display the result in List, how can I make my program faster.
|
|
|
|
|
You need to either filter the results so that the user starts getting only the results that they are interested in (let's face it, no-one wants to scroll through 600000 results to find the ones they want), or you need to institute some sort of paging, i.e retrieve only a few results at a time and give the user buttons or links to go forward or backward. Unfortunately, I can only be vague in my answer as you are vague in your question. If you give us more information, perhaps we can give you more specific help.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Actually before I display any record user must input a filter. My problem is when I Open a ResultSet its takes 10 or more seconds to display to List. Is there a way to make the query fast.
|
|
|
|
|
It still seems like the resultset is too large, that is what is taking the time. In that case, you would need to set up paging and only return a few results at a time, and give the user options to move forward and back - similar to what happens here on the forums. You generally only see the first 25 / 50 posts on the page at a time and if you want to view any other posts from before you need to go to a different page.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I's sorry but the resultset is not large, actually it returns just one record.
|
|
|
|
|
That then would point to either
1. Indexing on the database
2. Your query for getting the single result
3. Code used to execute query.
They are in the order that I would check
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
have your database properly indexed.
warning: more (and more complex) indexing gives faster look-ups and slower inserts.
|
|
|
|
|
"MDB" is a Microsoft Database, could be either Access or Sql Server. Any large list will take time to go from A (the database) to B (the memory of your app).
As another alternative, have a look at the VirtualMode[^] of the DataGridView . Works fastest using the DataGrid , if you don't mind the ugly interface (loads faster than loading a table in Sql Management Studio)
Bastard Programmer from Hell
|
|
|
|
|
hi everyone,
I always got an error Restore failed for Server '...\SQLEXPRESS'
I googled it already and bunch of result.
but still, i can't solve it.
Details:
*windows xp
*sql server 2005 using PCNAME\SQLEXPRESS, (windows authentication mode)
*visual studio 2005
*filePath= C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\DBNAME.bak
note: sometimes it goes successfully but sometimes got an error.
please help! thanks in advance.
here's the code
Using cnn As New SqlConnection(constrSQL)
cnn.Open()
dbName = cnn.Database.ToString()
cnn.ChangeDatabase("master")
Dim sc As New ServerConnection(cnn)
Dim sv As New Server(sc)
filePath = Path.Combine(filePath, databaseName & ".bak")
Dim bdi As New BackupDeviceItem(filePath, DeviceType.File)
Dim resDB As New Restore()
resDB.Database = dbName
resDB.Action = RestoreActionType.Database
resDB.ReplaceDatabase = True
resDB.NoRecovery = False
resDB.Devices.Add(bdi)
resDB.PercentCompleteNotification = 10
AddHandler resDB.PercentComplete, AddressOf ProgressEventHandler
resDB.Database = dbName
Try
resDB.SqlRestore(sv)
sv.Refresh()
sv = Nothing
Catch ex As Exception
log.Debug(ex.ToString)
Throw (ex)
End Try
End Using
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
There may be active uses on the db when you are trying to restore a backup..
|
|
|
|