|
You can handle the keyboard events, maybe set myForm.KeyPreview true.
It is however much easier, if you have menus, to add a MenuItem for the action you want, and assign
a shortcut to that menu item. Then no extra code is required.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I have a problem with inheriting in VB that has been beating me for two days now. I have one base class, all the variables are private with public wrappers for set and get. I also have several derived classes.
The functions and subs have all been overridden and everything works fine, but I can not change the public properties to modify the set methods. Everytime I do, I get an error using everything but MYBASE.Whatever, but using the MYBASE calls gives a strange value and I can't find out how it is occuring.
My question is. Can I override one of the public properties and change how the set method works, or do I have to re-declare the variable in the derived class to do it?
|
|
|
|
|
Veldrain wrote: My question is. Can I override one of the public properties and change how the set method works, or do I have to re-declare the variable in the derived class to do it?
If you want to override the behaviour yet continue to use the field on the base class you must change the field to be Protected. Private means it is accessible only to the class that defined it and no others. Protected means it is accessible only to the class that defined it plus any derived classes.
|
|
|
|
|
Thank you Colin. Every book and tutorial I found only mentioned overriding Functions and Subs. I was beginning to think properties were impossible to override, and that just didn't make sence.
|
|
|
|
|
Any member that you want to override has to be virtual (Overridable in VB). If you add a new implementation for a member that is not virtual, you will be shadowing the member instead.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
|
Hi,
Sorry to say but I am not very clear about the issue you are facing. I would like to confirm whether you are using Mnemonics as short keys. If yes, then I would like to mention that Mnemonics gets activated when we press the Alt+ (underlined character). For example if you have defined the caption (Text) of a Button as “Click Me” (note the underlined C here). The button will be clicked automatically when user presses Alt+C.
If this is the behavior you are facing then please know that it is a default behavior.
I hope this helps. Please let me know if I have missed something.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
You got my point. Thank you so much for reply. This is possible by small setting in system.
The option given works.
|
|
|
|
|
This is a system setting and has nothing to do with your code.
Right-click a blank area on your desktop and pick Properties. On Windows 2000, under the Effects tab, you'll find "Hide keyboard navigation idicators until I press the Alt key". For Windows XP, it's under the Appearance tab, Effects button.
|
|
|
|
|
Hi guys.
I have the script of a stored procedure in a .txt file. I need to search for
a particular word in the file and add a line with information above that word.
The file contains this information:
CREATE PROCEDURE SalesByCategory<br />
@CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998'<br />
AS ---------------WORD TO SEARCH---------------<br />
IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998' <br />
BEGIN<br />
SELECT @OrdYear = '1998'<br />
END<br />
<br />
SELECT ProductName,<br />
TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0)<br />
FROM [Order Details] OD, Orders O, Products P, Categories C<br />
WHERE OD.OrderID = O.OrderID <br />
AND OD.ProductID = P.ProductID <br />
AND P.CategoryID = C.CategoryID<br />
AND C.CategoryName = @CategoryName<br />
AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear<br />
GROUP BY ProductName<br />
ORDER BY ProductName
I need to search for the AS word or the AS clause, you know the one that is after the parameters definition.
Once i have found that word i need to add the WITH ENCRYPTION clause above the AS CLAUSE, then the script would
look like this:
CREATE PROCEDURE SalesByCategory<br />
@CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998'<br />
WITH ENCRYPTION ---------------ADDED WORD---------------<br />
AS ---------------WORD SEARCHED---------------<br />
IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998' <br />
BEGIN<br />
SELECT @OrdYear = '1998'<br />
END<br />
<br />
SELECT ProductName,<br />
TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0)<br />
FROM [Order Details] OD, Orders O, Products P, Categories C<br />
WHERE OD.OrderID = O.OrderID <br />
AND OD.ProductID = P.ProductID <br />
AND P.CategoryID = C.CategoryID<br />
AND C.CategoryName = @CategoryName<br />
AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear<br />
GROUP BY ProductName<br />
ORDER BY ProductName
So...what i need to do is searching a word in the text file and then add a line above that word.
I have some ideas in my mind but i would like to know your opinions about how i could solve this.
Thanks for your time and regards...
Henry de Sousa
modified on Monday, January 21, 2008 8:56:05 PM
|
|
|
|
|
Use the Replace command in VB for example
<br />
Replace(mySQL, ControlChars.CrLf & "AS ", ControlChars.CrLf & "WITH ENCRYPTION AS ")<br />
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Thanks for your help!!
I'll post the code when i have all my code done.
Henry de Sousa
|
|
|
|
|
Hello,
I have been trying to get the contents of a registry entry. I tried the following:
'http://www.andreavb.com/tip080001.html
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, _
ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long _
) As Long
'http:
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Sub Form_Load()
RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
0&, KEY_READ, hKey
RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
End Sub
After the RegOpenKeyEx is executed, hKey has a value of 0. Something doesn't seem right here. Can anyone help?
Regards,
Mike
modified on Tuesday, January 22, 2008 9:37:31 AM
|
|
|
|
|
I changed Form_Load as shown below:
Private Sub Form_Load()
HKEY_LOCAL_MACHINE = &H80000002
KEY_READ = &H20019
RegOpenKeyEx HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", _
0&, KEY_READ, hKey
RegQueryValueEx hKey, "CommonFilesDir", 0, 0, sValue, iTemp
End Sub Now, I'm getting a non-zero value for hKey, but still I'm getting nothing for sValue. Anyone have any ideas?
Regards,
Mike
modified on Tuesday, January 22, 2008 10:49:23 AM
|
|
|
|
|
I am trying to display some data from a database withing a gridview. Using a few books, i have managed to display the data in a msngbox but im having problmes displaying it on the asp webpage. Heres what i have at the moment:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconnection As OleDbConnection
myconnection = New OleDbConnection()
Dim connectionString As String = "provider=Microsoft.Jet.OLEDB.4.0;" + _
"data source = C:\Documents and Settings\admin2\My Documents\glaxodata.mdb"
myconnection.ConnectionString = connectionString
Dim mycommand As OleDbCommand
mycommand = New OleDbCommand("select * from glaxoAll5032007OrderDetail", myconnection)
Dim myreader As OleDbDataReader
myconnection.Open()
myreader = mycommand.ExecuteReader()
myreader.Read()
Dim newrow As DataRow
MsgBox(myreader("Field1"))
Dim mytable As DataTable
mytable = New DataTable()
mytable.Rows.Add(newrow)
MsgBox(mytable.Rows.Count)
mytable.Rows.Add()
GridView1.DataSource = mytable
myconnection.Close()
End Sub
can any1 help?
|
|
|
|
|
Hi!
I dint understand why you are using ExecuteReader? It returns single record right?
If you want to bind more than one record get data to datatable directly and bind to the gridview
'GridView1.DataSource = mytable' after this line add the following line
'GridView1.databind()'
|
|
|
|
|
How do I find out how many rows are retrieved using a select statement and a table adapter?
I need to use this number in a for loop.
Greg
|
|
|
|
|
If you have populated a table with your select statement then you can get a count with MyTable.Rows.Count
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
I tried using MyDataTable.Rows.Count and I get the blue line.
Does it matter if I am using typed or untyped datasets?
|
|
|
|
|
MyTable is the name of the Table object for example
Dim myDataSet as new System.Data.DataSet<br />
'Populate your dataset here<br />
<br />
Dim MyTable as System.Data.DataTable<br />
MyTable = myDataSet.Tables(0)
The Rows.Count works on both typed and untyped datatables
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
To use that code do I have to import any particular namespace?
|
|
|
|
|
I have a ListView control in a form. I want to add a "Select All" button on the form that selects all items in the ListView control. I cannot find a way to do this. The "SelectedIndices" and "SelectedItems" are readonly properties.
How do I programatically select an item in the ListView?
|
|
|
|
|
Here's how you do it:
For Each item As ListViewItem In lv.Items
item.Selected = True
Next
lv.Focus()
Note that you need need to set the focus back to the ListView control, because the items won't be highlighted when the control does not have focus (by default, lv.HideSelection = true). Instead of giving focus back to the control, you could set the lv.HideSelection to false, but the highlight will be gray instead of blue (when the control does not have focus).
|
|
|
|
|
Hello, I am working on a VB.Net application, which is called from another application and accepts commandline arguments. I want to strict users from opening multiple instances, instead I want to load existing instance and run a particular form based on the command line argument.
I will appreciate if someone help me out.
Thanks
|
|
|
|
|
This will determine whether or not your program is already running :-
Function IsAlreadyRunning() as Boolean<br />
Dim currentProcess As Process = Process.GetCurrentProcess()<br />
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)<br />
<br />
If allProcesses.Length > 1 Then<br />
Return True<br />
Else<br />
Return False<br />
End If<br />
End Function
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|