Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I have three drop down lists in page1. DDL2 is values are dependant on DDL1, DDL3 values are dependant on DDL2. Once I select DDL values I have submit button that takes the values from these DDL values and redirects to appropriate page based on case statements. Now the issue is the new loaded page is opening with DDL values default to their first value rather than retaining the vales from prevous page values. Can someone help on retaining the values of the DDL between response.redirects.
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.
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.
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.
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)
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 />
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
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
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.
Thanks and regards
does dll hell term has anything to do with the partial classes.
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.
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.