|
Calling Focus() won't change the tab selection. Plus a control won't gain Focus if it's not visible. You're going to have to show the tab page yourself.
Now, if you want to keep it generic, I suppose you can do something like this. Just pass the control you want to give focus to in this function. It's just that easy.
Private Sub SetControlFocus(ByVal ctrl As Control)
' Validate argument.
If (ctrl Is Nothing) Then Return
' If control belongs to a tab page, then show it.
If (TypeOf ctrl.Parent Is TabPage) Then
myTabControl.SelectedTab = DirectCast(ctrl.Parent, TabPage)
End If
' Give control focus.
ctrl.Focus()
End Sub
|
|
|
|
|
I don't know if this problem has already been addressed or not, so please forgive me.
We all know that if we have more than one application running we can toggle through them by press the key combination alt+tab and a little window will show up showing us the icons of every application running. We press alt+tab to move from icon to icon until we find the one we want and then we release the alt and tab keys and we go right to the application we selected.
When I'm running a VB project and I toggle from the running application to another I noticed the Icons I designed have for the VB project don't show up in the tab window. It is just the standard VB icon for a form. How do I set it so it shows my icon?
Thank you,
Quecumber256
|
|
|
|
|
Did you set the Icon property of your form to one of these icons?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes. I have it in the Sub Form_Load. Here is the code snippet.
frmCreateDoc.Icon = LoadPicture(App.Path & "\Create32.Ico")
It shows the icon of the form, but not on the alt+tab.
Thank,
Quecumber256
|
|
|
|
|
LoadPicture, or whatever you're using isn't going to work. You actually have to use the Icon class.
frmCreateDoc.Icon = New Icon(Path.Combine(App.Path, "Create32.ico"))
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
frmCreateDoc.Icon = New Icon(Path.Combine(App.Path, "Create32.ico"))
Sorry, this gave me a compiler error. Expected end of statement.
Am I missing some required component or resource?
Thanks,
Quecumber256
|
|
|
|
|
Imports System.Io at the top of your code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave,
Received another compiler error. Method or data member not found.
Obviously I don't know exactly where this will go. Is it in the General Declarations are? The Sub Main as a defined as a public class?
Thanks again,
Quecumber256
|
|
|
|
|
I just assumed you would be putting the ...Icon= line in the same place at the one you posted. That line MUST go in some Sub or Function somewhere, usually inside the Form.Load event handler.
Damn! Sorry! The Icon class is in the System.Drawing namespace. Make sure you add a Reference to System.Drawing.dll.
Imports System.Io
Imports System.Drawing
Public Class Form1
Private Sub Form_Load(blah, blah) Handles MyBase.Load
Me.Icon = New Icon(Path.Combine(Application.StartupPath, "myIcon.ico"))
End Sub
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 20:48 Thursday 26th January, 2006
|
|
|
|
|
I am now completely lost. I added the reference to the System.Drawing.dll. When I try to do a full compile the VB doesn't recongnize either the .Io or .Drawing properties.
I think I'm going to have to have step by step instructions on how to use this.
Thanks for your help,
Quecumber256
|
|
|
|
|
Does your icon have a 32x32x256 color image in it?
After that, I have no idea what's wrong. I've never had the problem you're having.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Why not just set the forms Icon property in the designer?
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
Hi Ray,
I tried that. I even set the icon in the Form_Load event using code. The icon I designed for my application still does not show in the alt+tab window when toggleing through running applications.
Quecumber256
|
|
|
|
|
I tried it and it says its read only. Is there a way to change the style at runtime programmatically?
thanks,
sb
|
|
|
|
|
No, it's read only!
You can stack a couple of ComboBoxs on top of eachother if you want, set the Visible properties to False and just set the one you need to show at that time to True.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That I can do. Thanks for the idea,
sb
|
|
|
|
|
I have an application that has a treeview setup. Depending on the node selected on the treeview a datagrid is loaded with appropriate data from SQL.
At this point the treeview shows with the node highlighted and the datagrid is displayed with the data.
I want to have the cursor positioned in row 0 column 1. I tried the following logic:
DataGrid.CurrentCell = New DataGridCell(1, 0)<br />
DataGrid.Focus()
I'm having no success finding the correct syntax.
Any suggestions?
Lost in the vast sea of .NET
<a href="http://www.komputing.com/Pricelist.html">Visit my website at www.komputing.com</a>
|
|
|
|
|
Don't the Row and Columns numbers start with 1, not 0?
The Index's into the Row collections start with 0.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
When I have two records in the datagrid and use the code:
DataGrid.CurrentCell = New DataGridCell(1, 1)
the cursor doesn't blink anywhere till I click on the datagrid. At that point it blinks in the second row and second column.
If I use (0,0) and click on the header of the datagrid the cursor blinks in the first row, first column.
I don't want to have to click on the datagrid to start data entry. I want the end-user to click on the treeview node and then start data entry in the first row, first column without having to use the mouse to click in the appropriate cell or to click on the header of the datagrid.
Any other suggestions?
Lost in the vast sea of .NET
<a href="http://www.komputing.com/Pricelist.html">Visit my website at www.komputing.com</a>
|
|
|
|
|
OK. 0,0 it is. I've never had to change the CurrentCell myself...
Try setting the Focus to the DataGrid FIRST, then make the change to the CurrentCell.
DataGrid.Focus()
DataGrid.CurrentCell = New DataGridCell(0,0)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I had the logic like this:
DataGrid.CurrentCell = New DataGridCell(0,0)<br />
DataGrid.Focus()
I changed it to your suggestion of:
DataGrid.Focus()<br />
DataGrid.CurrentCell = New DataGridCell(0,0)
Neither way allows the cursor to be focused in the cell. If I set it to (1,1), the pointer on the side has the arrow pointing at the second record, so the CurrentCell logic is working but the Focus() is not.
I've also set the breakpoint on that line just to make sure I'm not going crazy and the logic wasn't being executed. It is.
Thanks for your suggestions...
Lost in the vast sea of .NET
|
|
|
|
|
KreativeKai wrote: I've also set the breakpoint on that line just to make sure I'm not going crazy and the logic wasn't being executed. It is.
Set the breakpoint on what line? Did it execute these two lines or not? What you said contradicts itself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The logic is executing. I set the breakpoint right above this section of code and stepped through the code.
Any other suggestions?
Lost in the vast sea of .NET
-- modified at 14:51 Friday 27th January, 2006
|
|
|
|
|
Here is the code I've used which works.
DataGrid.CurrentCell = New DataGridCell(0, 0)
SendKeys.Send("{TAB}")
SendKeys.Send("{TAB}")
SendKeys.Send("{TAB}")
SendKeys.Send("{HOME}")
This just doesn't seem like the best way to get focus on a datagrid.
Does anyone have a better suggestion?
Lost in the vast sea of .NET
|
|
|
|
|
I'm having a massive amount of trouble registering a VB.net created COM/ActiveX dll on another machine. Every time I try to register with regsvr32 it says "<myfile>.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered"
I have created the dll using the "Register for COM interop" option enabled and the dll works fine on my machine.
The test machine I'm using has the .net framework installed but just won't register the dll.
Am I doing something stupid? Any help would be greatly appreciated.
|
|
|
|