May 27 2008

Convert array of objects to array of strings

Published by turlach under dotNet

This is how to do it in one line in VB.NET. Very useful:

stringArray = Array.ConvertAll(Of Object, String)(objArray, AddressOf Convert.ToString)

No responses yet

Apr 01 2008

Combobox bug

Published by turlach under Visual Studio, dotNet, winforms

If you assign the same arraylist as a datasource for comboboxes on the same form they will appear to be linked together.

cbobox.datasource = al

I did not try to duplicate this effect but the solution I used was to iterate through the members of the arraylist and individually add items to the combobox.

For i = 0 to al.count-1

cbobox.list.add(al(i))

next

No responses yet

Jan 23 2008

Enable Text Editing in .NET DataGridViewComboBoxColumn

Published by turlach under Uncategorized

Here’s where the C# version came from: Devolutions.net

And here is the VB version:


   Private Sub dgvMacroGrid_EditingControlShowing(ByVal sender As Object,
            ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
            Handles dgvMacroGrid.EditingControlShowing
      'Enable text editing in combo cells
      If (dgvMacroGrid.CurrentCellAddress.X = colMacroLookup.DisplayIndex) Then
         Dim cb As ComboBox = CType(e.Control, ComboBox)
         If (cb IsNot Nothing) Then
            cb.DropDownStyle = ComboBoxStyle.DropDown
         End If
      End If
   End Sub

No responses yet

Nov 01 2007

Online Thumbnail Generator released.

Published by turlach under Announcements

A first version of a tool to generate thumbnails online has been released by Transatlantic Technical Services at http://thumber.bigplain.com. Designed to be simple and fast, you can upload your images, set the crop size and scale interactively and get a thumbnail easily. It is intended to be the first in a series of image manipulation tools, each making it easy to do just one thing.

No responses yet

Sep 14 2007

Using Word checkbox form fields as radio buttons

Published by turlach under Microsoft Office, VBA

Based on an article on word.mvps.org here is an enhanced version of a routine to make Word checkbox formfields act as radio buttons when grouped by Frame or in a TableCell.

Notes:

  1. Assign routine to both Entry and Exit events
  2. Routine will work with both mouse and tab/spacebar. With tab, 2 boxes may simultaneously appear checked until you exit the selected checkbox.
  3. I trapped some kind of strange bug that occurred for me in Table cells. Details in the code.

 


Sub MakeCheckBoxesExclusive()

   Dim oField As FormField
   Dim oCheckedField As FormField
   Dim bChecked As Boolean
   Dim oContainer As Object

   On Error GoTo errtrap

   '\ Figure out if checkboxes are grouped by frame or table cell
   If Selection.Frames.Count > 0 Then
      Set oContainer = Selection.Frames(1)
   ElseIf Selection.Cells.Count > 0 Then
      Set oContainer = Selection.Cells(1)
   End If

   '\Get the value of the current checkbox
   '\If it is checked then it will be the checked box
   bChecked = Selection.FormFields(1).CheckBox.Value
   If bChecked Then
      Set oCheckedField = Selection.FormFields(1)
   Else
      '\Selected box is not checked
      '\Look through other boxes for checked box
      For Each oField In oContainer.Range.FormFields
         If oField.CheckBox.Value = True Then
            Set oCheckedField = oField
            Exit For
next_field:
         End If
      Next oField
   End If

   '\Uncheck all the boxes
   For Each oField In oContainer.Range.FormFields
      oField.CheckBox.Value = False
   Next oField

   '\Check the designated box
   If Not oCheckedField Is Nothing Then
      oCheckedField.CheckBox.Value = True
   End If

   Exit Sub

   errtrap:
   '\ This error occurred when enumerating formfields in table cells
   '\ Some fields enumerated as strings or numbers
   If Err.Number = 4120 Then
      Resume next_field
   Else
      Err.Raise Err.Number
   End If

End Sub

No responses yet

Sep 14 2007

Code signing in VBA

Published by turlach under Uncategorized

On several occasions I have encountered a spurious “Disk Full” Error when trying to save a VBA project after a digital signature was applied. Several online sources suggested that there might be a broken reference (Tools|References). In my case, I had some subroutines in the ThisDocument module that had been used to process clicks on WinForm objects that were later removed from the document. Commenting out those routines solved the problem.

No responses yet

Sep 02 2007

Website readibility

Published by turlach under Uncategorized

Courtesy of a link on digg  is a link to a study showing that most people read web pages in an F shaped pattern, reading the first two paragraphs and then down the left side of the page. Something to consider when adding content to your layout.

No responses yet

Sep 01 2007

Free ASP.NET hosting

Published by turlach under ASP.NET, Opinion, Visual Studio, dotNet

Came across this fresh posting at an MSDN blog about free ASP.NET developer hosting at Verio until Jan 2010. The price is right. In the late nineties, I was partner in a business that hosted with Verio, and was never happy with their service, but getting something for nothing is definitely a better deal.

No responses yet

Aug 28 2007

Web browser.

Published by turlach under Opinion

Over the years I’ve used several browsers. I liked Opera and only switched to Firefox because they had a version (7 or 8 ) which was a real pain to install. But it ran fast and even though early Firefox versions were supposed to be quick, I never had the same feeling. For the last month or so, my main Windows browser has been K-Meleon. Like Firefox, it’s based on the Gecko engine, so everything renders beautifully, but it’s much barer and faster - None of the recent Firefox memory leak bloats. Unless you are wedded to some Firefox extensions, I’d suggest giving it a try. I still use Firefox for Firebug and the Web Developer bar plugins but straightforward surfing is all in K-Meleon.

It won’t be entirely painless. A few of the keyboard shortcuts are different, and some Flash content doesn’t load (YouTube has no problem), but I’ve had no problem with any Ajax apps and it is worth it for me.

No responses yet

Jul 27 2007

Disappearing events in Visual Studio 2003

Published by turlach under ASP.NET, Visual Studio, dotNet

Working in ASP.NET 1.1, I’ve been encountering a bug in VS2003 where event handlers are no longer allocated. e.g the “handles btnName.click” code disappears from the subroutine definition. One way to fix is to go back into the code and type the handler code, another to try re-clicking the control in the visual editor. I not the only one who has encountered this.

No responses yet

Next »