Question

I have an old VB6 Project that I am trying to convert to .NET. In the project vbLeftJustify was used. What is the .NET version of vbLeftJustify?

.set_ColAlignment(j, vbLeftJustify)
Was it helpful?

Solution

Edit: Reivised as @Hans Passant pointed out:

You are confusing vbLeftJustify with flexAlignLeftTop

If you are using an MSFlexGrid pass the value "0" for the flexAlignLeftTop as per here: ColAlignment, ColAlignmentBand, ColAlignmentHeader Properties (MSHFlexGrid)

If you are using a DataGridView:

There is no vbLeftJustify in vb.net in order to align the DataGrid properly you will need to set the DefaultCellStyle of the Column header like so:

Dim DataGridViewCellStyle1 As DataGridViewCellStyle = New DataGridViewCellStyle()

DataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft
Me.Column1.DefaultCellStyle = DataGridViewCellStyle1

OTHER TIPS

it is a flex grid, "MSFlexGrid"

You are supposed to use flexAlignLeft. Column alignment doesn't have anything to do with justification, just alignment. Its value is 0 as well so this worked correctly by accident.

This got notably fixed, you can't make this mistake anymore in VB.NET. Enum values now have associated type, it is not just a constant anymore.

Getting your project migrated to VB.NET is certainly easier when you keep the old VB6 controls. Do beware the deployment headaches, you still need to get that OCX installed on your user's machine. Moving to DataGridView is your long-term solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top