.net custom control with databinding to a property

Recently, I’ve been writing a custom control that extends a command button.

The premise is quite simple, the control cycles through a list of user provided colours, changing the background colour on each click to the next one on the list, wrapping around to the beginning when it reached the end.
(the CMS I was developing for a client required a series of flags that could be set to alert the user to details about the person calling [eg, problem client, unpaid bill, priority client etc])

As I wanted to save the value of the current I wanted to make the button data bindable. Each time the button is clicked the value of a property is incremented to represent the current flag state, this value would be databound.
Unfortunately, although the value updated internally, it wouldn’t push the changes through the databinder automagically for me. The state index would be set on load, changing the colour to the required value, meaning that the databinding is indeed working, but that there was nothing causing the binding manager to write the changes back the other way.

After a little reading, and some autocomplete-fu I got my solution, 1 line of code forcing the databinding to write its changes.

Public Property StateIndex As Int32
Get
  Return iStateIndex
End Get 
Set(ByVal value As Int32) 
'relevant code
  Me.DataBindings.Item("StateIndex").WriteValue() 
'
End Set 
End Property

Storage Space – part1: Concept

This entry is part of 1 in the series Storage Space

Having recently shifted house, I have the opportunity to redesign and rebuild my living environment. Typically this would just involve choosing where to put my bed, and what corner I’ll put my desk into. Luckily, the place I have moved into has nothing in the way of cupboard space, and having rid myself of most of my furniture in order to fit into my last couple of houses, I find myself a little wanting for places to put things. » Read more…

Loading offline registry files

Windows stores its registry information in a set of files known as hives.
You can access the registry of a running computer via the registry editor (run…->regedit), pretty obvious yeah?
But what if your pc is toast? how do you access the registry of it then? (maybe you got too many viruses, maybe you have a product key you want to extract, maybe you’re just a curious little bastard)

Interestingly you can use regedit still to look at offline hives. » Read more…

Correctly maximising MDI forms

I recently encountered an odd little quirk in visual .net.

When you create an instance of a form, as an MDI child, if you set the WindowState property to maximised, your form will not correctly span the whole window until you resize the parent.

After a bit of investigating on the internet, I came across many weird and wonderful suggestions,
things like setting the dock state of the form to ‘fill’, which works, right up until you want to un-maximise the form.

by far the easiest solution I have so far is as follows

dim frmMyFormInstance = New frmformTemplate()
With frmMyFormInstance
  .MdiParent = frmParent
  .Show()
 ' setting state in property of form results in incorrect display
  .WindowState = FormWindowState.Maximized
End With

That’s it, simple. Nothing fancy required like docking the form, or creating custom constructors that set properties before calling InitializeComponent(), just show the form, and then maximise it, not the other way about.

hunger and need

A man who hungers
will be more grateful of food
than he who is full

If at first..

If at first you don’t succeed,

Try Smarter.

undocumented windows feature: emergency restart?

Just stumbled on something interesting in windows 7
in order to do an “emergency restart”

  1. press control+alt+delete to bring up the menu screen
  2. press tab 3 times, this should select the power off button
  3. now push the menu key (that one between ctrl and alt on the right)
  4. you should get a message asking you if you want to do an emergency restart.

What the purpose of this is over a normal restart is, I’m not 100% sure. I guess it’s just forcing all processes to terminate without waiting for a response from them.

Regardless of use, there’s a little 4am morning curiosity for you.

That damn buzzing sound

Getting a little sick of the default windows mobile ringtone, I decided to sit down and smash out something a little different.

after about half an hour of fiddling about on my midi keyboard and various bits of music software, I ended up with something a little more lively.

Grab a copy below if you’re interested :)

8BIT-Dancer-Ringtone

The Mo-ject

Like a project, but, it’s about Mo’s…

This year I am participating in Movember, a pretty worthy cause if ever there was one. See, as blokes, we don’t really tend to pay too much attention to our general well-being, the general attitude is, ‘ah she’ll be right, just walk it off’

Movember is all about raising awareness that every now and again, we need to stop and make sure all our bits and pieces are all still attached, That everything is all still in working order, both physically and mentally. » Read more…

You Just Realised…

noseskull