|
OK I see your problem more clearly. How many list entries are you talking about? 100, 1000, 10000? I don't have a complete answer but I'd tackle it like this:
1. Set the DropDownStyle to DropDown (not DropDownList) then you get partial functionality whereby the combobox will allow entry of non-ListItem text. When the user hits the down arrow the entry in the list that starts with the entered text (if one exists) is auto selected.
2. Override several of the combobox events to capture the entered text character by character and auto-complete the text depending upon the combobox's ListItems (i.e. if there is an entry that starts with the entered text, set the Text property to match it etc).
3. If there is no corresponding entry in the ListItems do nothing yet. You can then programmatically determine whether or not to add this to the combobox's list or store it for future use.
These suggestions may already be implemeted in code you've obtained elsewhere. My advice though is to customize the operation of the ComboBox rather than roll your own since a lot of the work has already been done for yuu - unless there is good reason to abandon it.
...Steve
|
|
|
|
|
Hello Steve,
I have fixed the problem!
The estimated number of entries is about 2,500, although it may be more. I copied all of them into MS Word, each entry taking up one line, and it was 61 pages long! Thus, I didn't want to use a ComboBox for this.
However, searching through this site, there were a few things for autocomplete for a ComboBox. None of them worked for even a ComboBox. I edited the code up so that it would work correctly. Then, I edited the code even more to replace the ComboBox items with the arraylist items. I had to add a few things to make up for features that were included with the ComboBox that weren't with the array list(like the search features). I also had to add some code to get the selection stuff to work properly, but for the most part it worked fine.
Also, because it's SO terribly slow to search through 2,500+ items in an arraylist, I am using multiple arraylists. When it's ready to search, it finds out which arraylist to use and searches in that one. The result? MUCH faster and MUCH smoother running.
Thank you for your time!
If anyone else is interested, I would be glad to e-mail you the result.
|
|
|
|
|
Glad to hear you've solved it Matthew. Please feel free to write an article for The Code Project with your solution. I'm sure that others will be interested.
...Steve
|
|
|
|
|
This is the best I could come up with, not very good coding, but it's all I got and hopefully it'll help you get what you need. This works on buttons only, and you need to hit the button for it to check.
This code does NOT work. There's a problem with the indexof that I can not figure out, and therefore I'm posting this after 1hour+ worth of thoughts and this is it. This is not advanced coding by the way, just how I would come about this issue.
Dim database(99) As String
Dim counterbtn As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
counterbtn += 1
database(counterbtn) = txtbox.Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim wordlist(99) As String
Dim r As String
Do
Dim b As String = txtbox.Text
counterbtn += 1
r = database(counterbtn).IndexOf(b)
If r <> 0 Then
wordlist(counterbtn) = database(counterbtn)
End If
Loop Until counterbtn = "99"
End Sub
|
|
|
|
|
How will I going to open a file and browse from it like read/write?
If so happen that I'd like to call a VC++ function or classes from their program, How? Is it possible? Newbie here, sorry
|
|
|
|
|
I'm sorry but I cannot understand what you are talking about. I realize that English may not be your native language but we must have a more coherent question before we can attempt to understand and then help you.
From what I can read between the lines of your post you want to do some very basic file operations from within a program? If so, a Google[^] search will probably find you more help in the first instance than this board.
...Steve
|
|
|
|
|
VC++? --> Throw New Exception("Wrong Board")
To Browse for a file have a look at the OpenFileDialog Class in the MSDN, it's ready to use.
To Open a File you can use old legacy Open VB statement (definetly not advisable) or open it through one of the .NET provided classes. It really depends on the file content and waht are you to do with it.
|
|
|
|
|
hi all,
I need some help in Vb.net or VB6 i would like to retrive the public IP of the system which is similar to the http://www.nirsoft.net/show_my_ip_address.php i would like to Retrive even if i a behind the firewall. Can any one help me on that. If you have one please mail me the code to
suresh@fuseflow.com
Thanks in Advance
Sur
|
|
|
|
|
You have two options to write this application.
1) You can write an application to try to resolve the host name assigned to you by your ISP. This will usually return the IP address assigned to you. (This one is easier!)
2) Or, you can write your application to talk to your router and get the address from either a telnet server on your router or from a web page from your router. In iether case, you'll have to parse the data returned to get at the address.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Does VB .NET 2003 have a bug with the UrlEncode method?
It will not convert ' to %27
As a result HREF using Request.QueryString.ToString fails due to an extra quote.
For example:
F1="Fred's Fish"
F1 = Server.UrlEncode(F1)
'F1 returns "Fred's+Fish"
I am having to write a replacement function for UrlEncode.
Gary
|
|
|
|
|
There are no known issues with the .UrlEncode() method.
But since you're putting this path into an A HREF tag, shouldn't you be using .UrlPathEncode() instead?
HttpServerUtility.UrlPathEncode Method[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for responding.
I don't need .UrlPathEncode since I am creating a custom link to another page.
As for the .UrlEncode shouldn't it encode a Quote character?
I have traced it and a ' does not encode to %27. What am I missing?
Gary
|
|
|
|
|
I would like to save the Font properties of the control in a text .ini file to retreive these properties by reading again the file.
There is a brute force way of doing like:
sw.WriteLine(ListView1.ForeColor)
sw.WriteLine(ListView1.BackColor)
sw.WriteLine(ListView1.Font)
It gives the following result(by example):
Color [WindowText]
Color [WhiteSmoke]
[Font: Name=Arial, Size=9,75, Units=3, GdiCharSet=0, GdiVerticalFont=False]
Then to retreive the properties we must parse each lines to extract the values.
This is wordy and not very elegant.
Is there somebody having a smarter way of doing?
Thank's in advance.
Patrice
-- modified at 13:52 Thursday 29th September, 2005
|
|
|
|
|
you can use the registry to save each property of the font in a variable.
when you want to retreive these properties from the registry... intiate a new font object with these retreived strings.
militiaware...Faris Madi
|
|
|
|
|
Thank you for your reply. Yes I have notice this possibility, but I do not want to use the registry. Due to portability issues I don't want this. The curious thing is that I have heard in a webcast a guy saying that there were NO MORE registry with .NET. I don't know if the framework does not need for itself the registry but, do Microsoft has provided a way to convert a string in a system.drawing.color object?
the instruction like :
ListView1.BackColor = "black"
give the error: Value of type string canot be converted to 'system.drawing.color'
That mean that the only way I see is:
sColor="black"
Select case sColor
case "red"
case "green"
...
case "black"
ListView1.Backcolor = color.black
end select
you see the work to save all the properties !!!!
I will check then saving the objects properties in a dat file with a record structure of object properties.
Patrice
|
|
|
|
|
maybe your right about ignoring the registry... idon't know...
if you got sur let me notice.
about the color ...
your can save the color to a string using ToArgs...
like:
str= listview1.backcolor.color.ToArgs
and get it back by
listview1.backcolor.color.fromArgs=str
i don't remember the right syntax by check it out
militiaware...........Faris Madi
|
|
|
|
|
Thanks Faris,
ToArgb doesn't exactly fit to my idea but is closest.
In fact I am working arround with :
ListView1.BackColor = Color.FromName("black") '// <-- accept strings
ListView1.Font = New Font("Arial", 8, 2, 0, 0) '// <-- also accept strings or values
or something like that.
The problem I have is that
sw.WriteLine(ListView1.ForeColor)
sw.WriteLine(ListView1.BackColor)
sw.WriteLine(ListView1.Font)
may give a variable number of values if the color is not named but selected custom that give instead three numbers.
|
|
|
|
|
Colors can be saved as a binary Argb representaion which describes the color as an integer value. Color objects can be recreated from the same binary value. You don't need to worry about strings or cases - just save and restore the binary representation of the color.
|
|
|
|
|
Ok then, will look at this further. I have found a solution resticted to the named colors that works properly.
Of course if we are using the custom colors provided by the ColorDialog control, then the use the ARGB parameters is probably the best idea.
And to save the fonts, have you any suggestion ?
Thanks for your help.
Pat
|
|
|
|
|
ARGB works for all colors I would use it in any case. As far as saving fonts, whether you use the Registry, and INI file, text file etc is up to you. The process is always the same - you have to save enough parameter values to recreate the font - Family, Style, Size, Color, etc
|
|
|
|
|
Well, saving all the font parameters looks easy to write in a single sentence:
recreate the font - Family, Style, Size, Color.
It would have been nice to have something like: ListView1.Font.ToString
ListView1.Font.FromString
What we have handy is more confusing :
assuming you have open sw as streamwriter
sw.WriteLine(ListView1.Font) writes :
[Font: Name=Times New Roman, Size=15,75, Units=3, GdiCharSet=0, GdiVerticalFont=False]
sw.WriteLine(ListView2.Font.Size) can give : 9,75 or 12
Question : how can we restore(well simply) a font size defined by : 10 12 9,75 or 15,75 ?
The only way I find is to parse the written string and analyse to look if we have a ',' in the size
and then convert it in 15.75
pfff!
Best Regards
Pat
|
|
|
|
|
So guys, with your help I have got it working pretty nice.
To put it all together and to clean up the table, for those interested:
How to save and restore fonts and colors from controls: (if there is a better way to do it just tell)
' Saving the parameters<br />
Dim sw As New StreamWriter("myInitFile.ini")<br />
' Color of Caracters<br />
sw.WriteLine(RichTextBox1.ForeColor.ToArgb)<br />
sw.WriteLine(ListView1.ForeColor.ToArgb)<br />
' Color of Background<br />
sw.WriteLine(RichTextBox1.BackColor.ToArgb)<br />
sw.WriteLine(ListView1.BackColor.ToArgb)<br />
'Fonts<br />
sw.WriteLine(RichTextBox1.Font.Name)<br />
sw.WriteLine(ListView1.Font.Name)<br />
'Size<br />
sw.WriteLine(RichTextBox1.Font.SizeInPoints)<br />
sw.WriteLine(ListView1.Font.SizeInPoints)<br />
sw.close()<br />
<br />
' retriving the parameters<br />
Dim sr As New StreamReader("myInitFile.ini")<br />
delimStr1 As String = "[] :,.=;"<br />
Dim delimiter As Char() = delimStr1.ToCharArray()<br />
Dim split As String() = Nothing<br />
Dim i, Pos, First As Integer<br />
Dim Words, s As String<br />
Dim token(16) As String<br />
For i = 1 To 6<br />
token(i) = sr.ReadLine<br />
Next i<br />
Pos = 6<br />
For i = 1 To 2<br />
Words = sr.ReadLine<br />
split = Words.Split(delimiter)<br />
Pos += 1<br />
First = 0<br />
For Each s In split<br />
If s <> "" Then<br />
First += 1<br />
If First = 1 Then<br />
token(Pos) = s<br />
End If<br />
End If<br />
Next s<br />
Next i<br />
<br />
RichTextBox1.ForeColor = Color.FromArgb(CInt(Val(token(1))))<br />
ListView1.ForeColor = Color.FromArgb(CInt(Val(token(2))))<br />
RichTextBox1.BackColor = Color.FromArgb(CInt(Val(token(3))))<br />
ListView1.BackColor = Color.FromArgb(CInt(Val(token(4))))<br />
RichTextBox1.Font = New Font(token(5), CShort(Val(token(7))))<br />
ListView1.Font = New Font(token(6), CShort(Val(token(8))))<br />
sr.close()<br />
That's all folks!
This is a simplified extract of my program which work nice. This is my little contribution and thanks your help.
Best regards
Patrice
|
|
|
|
|
One comment. There are APIs that allow reading and writing INI file without having to parse them line by line. For example, you can simply call a function to read or write a certain value from a specific key and section.
I created a module that wraps the apis in simple function calls. If you want a copy, send me your e-mail and I will send it to you.
|
|
|
|
|
What is the fastest way to push data to Excel?
I am iterating through an array and putting the data into excel using the activecell.offset. This takes forever for any reasonable amount of data. I am pushing data from a syncfusion grid; any clever tracks I could do??
|
|
|
|
|
I have a VBA app that exports the activesheet to an xml file. I know that app.config files are just another form of XML files. How can I get this app to export to .config files as well? I am using
ActiveWorkbook.XmlMaps("ConfigParameters_Map").Export to export the data to an XML file. Thanks in advance.
P
|
|
|
|