Posts Tagged ‘VB.NET’

Bullet Point Indentation on TextControl

Thursday, March 5th, 2009

I use TextControl .NET for a lot of the programs that I write – it is a great word processor component and works well for document based reporting as well.  However, there are a few niggling little bugs that annoy me.  One of them is bullet point indentation.  

I discussed this problem with the technical support people at TextControl and they said that I would have to write some code to catch the Changed event.  

I initially thought that this was a problem with the bullet point indentation itself, and then I noticed that if I added bullet points and removed them, the paragraph jumped back to 0 (default indentation is usually 500).  

After a bit of playing about, I discovered that I needed to change the selection’s paragraph format properties for left indent and hanging indent as follows: -

    Private Sub tcEditor_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles tcEditor.Changed

        If tcEditor.Selection.ParagraphFormat.LeftIndent < 500 AndAlso tcEditor.Tables.GetItem() Is Nothing Then            tcEditor.Selection.ParagraphFormat.LeftIndent = tcEditor.Selection.ParagraphFormat.HangingIndent + 500
        End If
    End Sub

This might look a little odd, but in order to set the left indent to the correct value, it needs to be 500 greater than the hanging indent in order to get the correct behaviour

Update on .NET 3.5 in Windows 2000

Monday, March 2nd, 2009

This has now been running fine for a couple of months and is being used on a day to day basis.  Not all functionality works perfectly out of the box, but most of the stuff I have tried can be worked around.  I’m using compilation on the fly using the VB.NET 3.5 compiler to make dynamic Linq to SQL queries, which I have needed to create a workaround using vbc.exe – the VB.NET compiler and passing in command line parameters.  I needed to copy in the required DLLs that it was complaining that it didn’t have, and a few extras as well that I threw in predicting that it might need them.  Let me know if you want more details – comment below.

More info on .NET 3.5 in Windows 2000

Thursday, September 18th, 2008

People have been requesting more information about whether my previously mentioned trick to get .NET 3.5 functionality in Windows 2000 works.  So far, it mostly seems to be a success although the software is still not being used on a large scale, but I have only found 1 real problem… When I made a WCF service client to access a web service, VS.NET created a section in the app.config file.  This caused an exception when I loaded the program on the Windows 2000 PCs.  However, I removed the section from the config file and hard coded the configuration info for the WCF client and it worked fine!

Microsoft .NET Framework 3.5 in Windows 2000 Test 1

Wednesday, March 26th, 2008

I mentioned earlier how to install .NET framework 3.5  in Windows 2000.  I have been testing this on 7 Windows 2000 PCs, and I have successfully managed to get them to do a simple Linq to SQL query with the method that I mentioned.  I can’t speak for WPF or anything, but I am currently only interested in Linq.  I will post more in future when I have the live system in place.

The .NET Stack Part 2: The StackTrace Class

Tuesday, March 18th, 2008
This entry is part of a series, The .NET Stack»

The StackTrace class is used to get a collection of StackFrames.  A StackFrame contains information about a single point in the Stack.  I’ll come back to that in a later post.  The StackTrace class has multiple constructors with various parameters: -

The Default Constructor (no parameters)
Gets the current point in the stack in this function that you are calling it from.

fNeedFileInfo as Boolean
Whether we need the line numbers, file names etc in the stack trace (if available).

skipFrames as Integer
The number of frames to skip.  1 starts with the function that called this function. 2 starts with the one that called that function etc.

e as System.Exception
An Exception to build the stack trace for.

frame as StackFrame
A frame that this stack trace should contain.

targetThread as Thread
The thread to get the stack trace for.

Since there are 10 different constructors in .NET 3.5 at the time I am writing this, there are plenty of combinations that these can be used in.

The StackTrace class has several members that are of interest: -

FrameCount
The number of frames that this StackTrace contains.

GetFrame(index as Integer)
Get a frame at a certain position.  See skipFrames (above) for what the position means.

GetFrames
Returns an array of the frames in the StackTrace.

Entries in this series:
  1. The .NET Stack Part 1: How The Stack Works
  2. The .NET Stack Part 2: The StackTrace Class
Powered by Hackadelic Sliding Notes 1.6.5

Nullables in VB.NET with ?

Friday, March 14th, 2008

I don’t know whether this is just in the new version of the VB.NET compiler which goes with Visual Studio 2008 or whether I just missed it completely in 2005, but I have just noticed that you can declare Nullables in VB.NET the same way you can in C#.

For example, you can do

Dim CustomerID as Integer?

Note the question mark on the end – this indicates that it is nullable.

Microsoft .NET Framework 3.5 in Windows 2000

Wednesday, March 12th, 2008

Microsoft don’t support using .NET 3.5 in Windows 2000, which is particularly annoying, especially if, like me, you have a client who has 8 out of 12 PCs still using Windows 2000.

So, I decided to have a go and see if I could find any way of doing it. This is completely unsupported, and if it breaks anything, don’t blame me, but it is actually fairly straightforward and it seems to work fine to me (although I doubt it works with things like WPF, but if anyone tries it, please leave a comment to say how it goes)…

  1. Make sure you have Windows 2000 SP4 installed
  2. You may need to install KB 835732 before step 3
  3. Install .NET Framework 2.0 Service Pack 1

Now, there are 2 ways of continuing. Either you can copy over all the .NET 3.5 assemblies (you’ll have them on a .NET 3.5 PC in the Program Files\Reference Assemblies\Microsoft\Framework\v3.5 folder). You can either dump them in the application folder or probably register them in the GAC (not tried it, but it should work).

Alternatively, try running your application. You will probably get a load of AssemblyReferenceFailedExceptions. Copy in the required DLL from the above folder into your application folder for each one.

It should all work now!