|
ok maybe i am explaining this wrong. Here's the actual scenario:
1. We query the server about all the possible city names available and fills the combo box with all the names. Eg. AA,AB,AC and AD
2. When the customer enters a phone number we search the database and if the phone number exists then i just want the combo box to show the city that the matches the phone number for Eg. AB is the city the number matches to then AB should be selected in the combo box. If the number matches no city then we do nothing.
3. We also DONT want the customer to be able to edit the combo box field.
4. The customer can also SELECT a city himself if he wants to by selecting a value from the combo box.
anyways thanks for even lookin at this
|
|
|
|
|
Correct me if I'm wrong, but I think I know what you want:
You want to set a specific text into the combobox (from one of the items in the list) through code and you don't want users to edit the combobox text.
There are several ways you can do this:
1. Use this function to get and set the index of the item (instead of the text) you want to select in the combobox while keeping your combobox style to 2:
Public Function GetComboBoxIndex(hWnd As Long, SearchKey As String, Optional FindExactMatch As Boolean = True) As Integer
'Parameters:
' hWnd - the handle to the ComboBox control. Usage: Combo1.hWnd
' SearchKey - item that you would like to search for. Can be any string - case doesn't matter when searching
' Optional FindExactMatch - Default is True. Pass False to find a partial match
'Return:
' Returns the index of the found match. If the match is not found, -1 is returned
'Usage:
' Combo1.ListIndex = GetComboBoxIndex(Combo1.hWnd, "Test Item")
' Combo1.ListIndex = GetComboBoxIndex(Combo1.hWnd, "Test Item", False)
If FindExactMatch Then
GetComboBoxIndex = CInt(SendMessage(hWnd, CB_FINDSTRINGEXACT, -1, ByVal SearchKey))
Else
GetComboBoxIndex = CInt(SendMessage(hWnd, CB_FINDSTRING, -1, ByVal SearchKey))
End If
End Function
2. Similar to #1, you can iterate through the combobox item and compare the text to get the index, but this is inefficient.
3. You can implement the AutoFill function on the KeyPress event and IsComboboxItemValid on the Validate event for the combobox. This enables user to type into the combobox (using style 0) but also makes sure that whatever they type will be in the items list.
Public Sub AutoFillCombobox(ByRef comboBox As comboBox, ByRef KeyAscii As Integer)
Dim intIndex As Integer
Dim intRemainder As Integer
Dim strFullText As String
Dim strPartialText As String
If comboBox.Locked Then
KeyAscii = 0
Exit Sub
End If
If KeyAscii >= 33 And KeyAscii <= 126 Then
comboBox.SelText = Chr(KeyAscii)
strPartialText = comboBox.Text
intIndex = GetComboBoxIndex(comboBox.hWnd, strPartialText, False)
If intIndex > -1 Then
strFullText = comboBox.List(intIndex)
intRemainder = Len(strFullText) - Len(strPartialText)
If intRemainder > 0 Then
comboBox.SelStart = Len(comboBox.Text)
comboBox.SelText = Right(strFullText, intRemainder)
comboBox.SelStart = Len(strPartialText)
comboBox.SelLength = Len(strFullText) - Len(strPartialText)
End If
End If
KeyAscii = 0
End If
End Sub
Public Function IsComboboxItemValid(ByRef comboBox As comboBox, Optional ByVal blnPrompt As Boolean = False, Optional ByRef Cancel As Boolean) As Boolean
Dim intIndex As Integer
intIndex = -1
If IsComboboxItemListed(comboBox, intIndex) Then
comboBox.ListIndex = intIndex
IsComboboxItemValid = True
Else
IsComboboxItemValid = False
Cancel = True
If blnPrompt Then
MsgBox "Item is not in the list." & vbCrLf & "Please select an item from the list.", vbInformation, "Item Not Available"
End If
End If
End Function
I hope one of those can help you.
Cheers!
|
|
|
|
|
THANKS !!
this is what i've been looking for. Sorry guys i guess was being a bit vague in the beginning . anyway the only thing missing is the IsComboboxItemListed(comboBox, intIndex) function and defination CB_FINDSTRINGEXACT i know this is kinda stupid to ask for everything but am a newbie to VB and this is probably the first thing i got stuck on in VB.
Thanks for the help dude..
really appreciate it
|
|
|
|
|
I can't access my PC right now, and this is what I found through Google.
If this doesn't work, try searching through Google again.
Private Const CB_FINDSTRINGEXACT = &H158
Cheers
Edbert P
|
|
|
|
|
I cannot see where the validator controls allow me to validate a string length. I can enter too many characters in the control and the results cause my sql to hit the 'Catch' ....also having a hard time finding reference to formatting strings like social security numbers, phone numbers and etc. Date is handled with the date options well but can't seem to comprehend how to do a custom format of a string?? All help appreciated.
JohnR
|
|
|
|
|
You can use the MaxLength property of TextBox in addition to the Validation Controls.
|
|
|
|
|
Thanks for the heads up on the maxlength, any help on the formatting. I have seen references to the maskededit.control, string.format and cannot seem to find an easy way to display format, without parseing the string, nor create an input mask. All help appreciated.
JohnR
|
|
|
|
|
I have a vb.net console app being executed by a sql job, however the job errors with the message ‘access denied’. The console app is located on a network server. How do I grant permissions, thus avoiding this error? Thank you,
Jason W.
|
|
|
|
|
Well, you have to check two things.
1) Check to see if the Windows account that the SQL job is running under has sufficient rights to the network location where the app is stored. If it's running under the Local SYSTEM account, then I guarantee that it doesn't.
2) .NET Framework apps running from a remote location (i.e. network) are not fully trusted and some functions, like writing to the file system, will throw all kinds of security errors, like Access Denied. Check to make sure that your code is running with sufficient trust. Read up on Security Policy Management[^] on MSDN for more information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have added the following in an attempt to resolve the error:
Dim ps As PermissionSet = New PermissionSet(PermissionState.Unrestricted)<br />
Dim sp As New SecurityPermission(PermissionState.Unrestricted)<br />
<br />
ps.AddPermission(New EnvironmentPermission(PermissionState.Unrestricted))<br />
ps.AddPermission(New UIPermission(PermissionState.Unrestricted))
Now I am receiving the following error:
Unhandled Exception: System.Security.SecurityException: <br />
Request for the permission of type System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, <br />
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. <br />
...<br />
The state of the failed permission was: <br />
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, <br />
Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode"/>. <br />
...
I admit at this point I am guessing as how to resolve the error. If possible I would like to put the app into unrestricted mode. I appreciate your thoughts?
Jason W.
|
|
|
|
|
Well, finish reading the link I posted yesterday and then go to Administering Security Policy[^] for a hint on how to add the correct permissions to the security zone that your app is going to be running under, since it's coming from a network share.
You can scrap the permissions code you posted. It won't work because your app can't request, and get, permissions that are denied by the security policy for the zone it's running under.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I add some custom controls I have created to a form at runtime ?
When the user clicks on a button, I want to add a custom panel object to the form.
I have tried something like this :
<br />
pnlTypeDeCiment = New pnlCementTypeFixed<br />
pnlTypeDeCiment.Parent() = Me.Parent<br />
pnlTypeDeCiment.SetBounds(100, 50, pnlTypeDeCiment.Width, pnlTypeDeCiment.Height)<br />
pnlTypeDeCiment.Visible() = True<br />
But without success.
|
|
|
|
|
Hi Leblanc,
try adding the panel to your forms Controls collection. This should work:
me.controls.add(pnlTypeDeCiment)
hope this helps.
-jim
|
|
|
|
|
WOuld it be feasable to instead of attempting to dynamically add controls, to add the panel at design time and then show/hide (.Visible) when necessary?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
This was my first idea, but for data loading reasons I had to scrap it.
|
|
|
|
|
Data loading reasons....what might they be? Couldn't you do something like:
<br />
On ButtonClick()<br />
<br />
GetData<br />
AddToPanel<br />
ShowPanel<br />
<br />
Or am I missing the reason completely lol!
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
The panels contain data grids which are bounded to data on an external database. With the 3rd party library which we are using when you bound an object like this, if retreives stuff from the db automaticly which I don't want to do everytime for bandwidth reasons.
I tought that by only creating the panels when they are used I would not create a panel the user never uses and thus save bandwidth.
|
|
|
|
|
This is actually a Visual Studio.NET problem. When I write a Turkish character in the source code files and then close/open visual studio, the IDE changes my Turkish character to another character which is not what I want (for example when I write "Uygulaması", it becomes "Uygulamasi"). I save the source file with Turkish-ISO encoding but the problem persists.
Did you encountered a problem like this before?
|
|
|
|
|
Add the following meta tag, save and then try whether it works or not.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
|
|
|
|
|
Hello,
I want to know that how to implement "SKINS" in VB.NET.
Kindly help me
EsHbAn BaHaDuR
|
|
|
|
|
You'll be searching for "Nonrectangular forms" on the web, but, as a head start...
Irregular Forms and Region Clipping[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi friends
i've got stuck about allocating one webpage into a specific frame, i do not know what system commands could be used to do so. when a user click on a link in one frame, that website should appear in other frame.
for example: i have a link button named Calendar, when the user click on this button, the calendar interface would display in the other frame.
could anyone help me please?
thanks in advance
|
|
|
|
|
Your question would be better handled in the ASP.NET Forum[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
Kindly help me ???
How can i read the (*.rtf) Rich Text Format
file through FILE HANDLING in VB.NET.
I want to use (RTF) extension so that file cannot lose its formatting i.e (bold, italics, font size etc).
plz help me
Regards,
Eshban
EsHbAn BaHaDuR
|
|
|
|
|