|
You should store the value in a session variable and then set it back to the DDL in the page load event.
Cleako
|
|
|
|
|
Trying to sort so that the text box only accepts caps from A-Z and not lower case and if so displays message box,
THANK YOU BEFORE HAND.
|
|
|
|
|
Inherit from the text box control and listen in through the WndProc or KeyDown or KeyUp events. If the key entered does not meet specifications then backspace and have the messagebox. You may also look into applying styles to the text box through Windows API, you could possibly search this site. I know you can apply a constant style like ES_Numbers (contant name is not correct, but it is similar to the actual constant) so that the text box can only accept numbers. Look for styles that begin with ES, and it may help.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Do an TextChanged or some other event and inside create a new regular expression with the values as (A-Z) or something like that, whatever is valid, and either return true if it matches or false if it doesnt.
Cleako
|
|
|
|
|
Why annoy the user if it's a lowercase letter, just convert it to uppercase for them. The following code will only allow letters and it converts them to uppercase. It also allows backspace, delete etc. If you want to message the user for invalid keys you could add a message here as well. Also as suggested before you may want to create your own control and inherit the textbox class, which will allow you to create a reusable control that has this validation built in. You could also simply add handlers so this routine handles all the textboxes you want validated. One other note, users will still be able paste invalid text into the textbox. You should validate this text in the validate event, or prevent users for pasting by setting the property 'ShortcutsEnabled' to false.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'If key press isn't control key (backspace...and others?) or a letter then ignore it
If Not (Char.IsControl(e.KeyChar) OrElse Char.IsLetter(e.KeyChar)) Then e.Handled = True
'Force capitalized letter
If Char.IsLetter(e.KeyChar) Then e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
|
|
|
|
|
Cheers mate i can see form this code that it will be very useful but cant get it working at moment the following code e.KeyChar = Char.ToUpper(e.KeyChar) keeps saying that it is read only is this code correct, thank you very much
|
|
|
|
|
The code is correct. I copied and pasted it from my editor. Everything worked fine when I tested it. In the keypress event e.KeyChar shouldn't be readonly. Please post the code you are using. If you didn't make any changes then it should work but post it anyway just so I can verify it. Also what version of Visual Studio are you using?
|
|
|
|
|
Hi using vb.net 2003 and the code is as follows got it working but with the properties but this code will be handy in future.Just curious to why it is not working.This is the only way it does not display read only on the last line so i use it but comment the last line out.
Private Sub txtRow_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRow.KeyPress<br />
'If key press isn't control key (backspace...and others?) or a letter then ignore it <br />
If Not (Char.IsControl(e.KeyChar) OrElse Char.IsLetter(e.KeyChar)) Then e.Handled = True<br />
'Force capitalized letter <br />
'If Char.IsLetter(e.KeyChar) Then e.KeyChar = Char.ToUpper(e.KeyChar)<br />
End Sub
|
|
|
|
|
I'm also curious. I've never used 2003 so I have no idea what's up with e.keychar being readonly. There has to be a way to change the key pressed. Your code is exactly the same as what I've used. Does 'e' hold any other properties for you. I have two properties 'handled' and 'keychar'. The other possibilty is that in 2003 you need to change the key pressed in the keyup event. Maybe they changed the readonly thing for 2005. However for me all the properties in the keyup event are readonly except for 'handled' and 'suppresskeypress'. 'Handled' doesn't actually seem to do anything
|
|
|
|
|
thank you got it working by setting the property to upper char casing and also using the code you sent stops them entering any other data, cheers
|
|
|
|
|
I always forget to check for the simplest solution
|
|
|
|
|
Sir/madam
Is it posible to pass two queries in sqldaaadapter/oledbdataadapter like
dim d as new oledbdataadapter(query1,query1,connection)
dim d as new sqldataadapter(query1,query1,connection)
Thanks and regards
Pankaj
|
|
|
|
|
You can write two queries in the query text if the database supports it. SQL Server does, Access does not.
e.g.
Dim d As New SqlCommand("SELECT * FROM Table1; SELECT * FROM Table2");
|
|
|
|
|
Sir,
I know something about the delegates but there is a little bit of confusion in strong type Term and does dll hell term has anything to do with the partial classes.
Please help.
Thanks and regards
Pankaj
|
|
|
|
|
amaneet wrote: does dll hell term has anything to do with the partial classes.
No.
amaneet wrote: there is a little bit of confusion in strong type Term
It means that you sign the assembly so that the types (classes and structures) are strongly typed. In other words, it helps with security as you need to create a key to sign the assemblies with. You would not distribute the key that you use to create the strong typed assembly, therefore if anyone tampers with your assembly, or attempts to replace it with their own, any application using the assembly will reject the doppleganger.
|
|
|
|
|
Sir/madam
I wanted to know something about the backward compatibility .I exactly don't know even which topic it is related with.
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
amaneet wrote: I wanted to know something about the backward compatibility
It means keeping the new API compatible with what came before it so that applications that used the old API still work with the new API.
|
|
|
|
|
Sir/Madam,
I am using the following query as a vb.net code to check whether the table in the database exist or not.
SELECT COUNT(*) AS TABLE_EXISTS FROM MSysObjects WHERE Name = 'Forms'
But there exist an error
Record cannot read
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
amaneet wrote: I am using the following query as a vb.net code to check whether the table in the database exist or not.
SELECT COUNT(*) AS TABLE_EXISTS FROM MSysObjects WHERE Name = 'Forms'
Knowing what database system you are using would be most helpful to diagnose the problem.
|
|
|
|
|
Select "Tools->Options" from the menu.
On the "View" tab-page tick "Show-System objects".
Select "Tools->Security->User and group Permissions" from the menu.
Choose "MSysObjects" from object names.
Tick "Read Design" and "Read" Permissions.
Regards
Andy
|
|
|
|
|
Sir,
I wanted to know something about the Generic Namespaces
Thanks and regards
Pankaj
|
|
|
|
|
I'm not sure what you mean. Do you mean the System.Collections.Generic namespace?
|
|
|
|
|
Sir/Madam,
In the form load i am writing
dim str as string
But did not need ant class to import.
How this can happen
please help.
Thanks and regards
Pankaj
|
|
|
|
|
I'm guessing it is an intrinsic type like Integer, Double or Boolean.
|
|
|
|
|
A String is an object just as in most langauges. It is derived from the System.Object class as System.String and is available by default in all new projects.
Cleako
|
|
|
|