June 2003 Archives

TreeNode Level

If you spend any time working with Treeviews, I can't imagine not needing this or having to invent it yourself:

Windows Forms FAQ - Windows Forms TreeView


Public Sub NodateLevel(ByVal node as TreeNode) As Integer

Dim level as Integer = 0

While Not node Is Nothing

node = node.Parent

level = level 1

End While

End Sub

I edited into this:

Private Function NodeLevel(ByVal node As TreeNode) As Integer
Dim level As Integer = 0
While Not node Is Nothing
node = node.Parent
level = level + 1
End While
End Function

Hide Datagrid Expanders

| 1 Comment

In the program I am developing, I wanted to show data from a table in a datagrid. This table is related to another table. As a result, this datagrid would show an expander and the name of that other table. I wanted this hidden. So I asked myself, "How do I hide the expander?" I didn't know so I searched and found the following:

Microsoft Support WebCasts

One DataGrid is designated to be the master grid and the second is designated to be the details grid. When you select an entry in the master list, all of the related child entries are shown in the details list. As you can see, there are no expanders shown on the master DataGrid. This is done by setting the AllowNavigation property of the DataGrid controls to false.

So there you have it set AllowNavigation to False. If you happen to find this useful, please link to this post as there is nothing that says to do this to hide them. I think this would be very helpful to others.

Version Number

I used information from Versioning an Assembly to be able to control the version numbers of my current project.


imports system
imports system.reflection
Imports System.Runtime.InteropServices

<Assembly: AssemblyTitle("")>

<Assembly: AssemblyDescription("")>

<Assembly: AssemblyCompany("")>

<Assembly: AssemblyProduct("")>

<Assembly: AssemblyCopyright("")>

<Assembly: AssemblyTrademark("")>

<Assembly: CLSCompliant(True)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("41BD3203-06FC-4FF4-8A74-3C842C207D49")>

' Version information for an assembly consists of the following four values:
' Major Version
' Minor Version
' Build Number
' Revision
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("")>

Long List of How To's

I stumbled across this list. I think it may be very helpful in the future:
Microsoft QuickStart Tutorials

Bringing a specific window to the top yet again

I was still having problems so I found this page:
Create a Form that Cannot Be Activated

From It I found this that seems to work better:

Private Declare Function BringWindowToTop _
Lib "user32" (ByVal hwnd As Long) As Long

Manipulating Word and Its SpellChecker pt. 1

Now that I have the handle for Word I need to make use of the Topmost function to raise it above the others. I found this page to be helpful:

VB TopMost Function

The most useful parts are:

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Public Sub MakeTopMost(Handle As Long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Public Sub MakeNormal(Handle As Long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Word's Classname

Method to cause an application to show a dialog box

Show Method

Here is how I used it:
x = WordApp.Dialogs.Item(WdWordDialog.wdDialogToolsSpellingAndGrammar).Show

Good Reference

kbAlertz! is a page that lists most (all?) of the Microsoft Knowledge Base articles, relevant to Visual Studio .Net. It can be very helpful in identifying what MS has to say about an issue.

Manipulating Word and Its SpellChecker pt. 1

In an effort to reuse the Spellchecker of MS Word, I have learned how to get it to check the spelling of a word or words. I have even learned how to get it to generate suggestions. I have, however been unable to convince it to reload the custom dictionaries after I have added a word to one of them. This is very frustrating because it makes me unable to have an effective form that works like the spell-checking dialog box in Word.

Having spent more time on this issue than I would like I decided why recreate something like the Word spell checker when it is just as available directly. Thus I thought I had solved my problem. I simply programatically paste the word or words I want to check into a blank Word Doc and then run the spell checker and then retrieve the corrections from Word for my application.

Alas I have found this simple plan to have one flaw. If my application is higher than Word in the Z-order, then the spell-check dialog box is placed behind my application. So I thought, this shouldn't be hard to fix, just raise the place of Word in the z-order.

Does .net have a way to do this?
Of course not (at least as far as my research has found), but there is a way to do it in older versions of VB. That method is to manipulate the Window via the Windows API. Technically this is still possible via .Net as well so I have decided to do it this way.

Enough background. What is this entry about? To manipulate a window via the API you need it handle. Thus the link:

302281 - HOWTO: Obtain the Window Handle for an Office Automation Server Using Visual Basic .NET

About this Archive

This page is an archive of entries from June 2003 listed from newest to oldest.

June 2001 is the previous archive.

August 2003 is the next archive.

Find recent content on the main index or look in the archives to find all content.