Monday, November 13, 2006

Pasting code into blogs, forums, etc

I just found out that this can be a real pain. Since I write my code in the Visual Studio editor I was able to use a macro to copy the code in a nice way. Modifying the code snippets by hand just sucks.

.Net 2.0 Forms DataBinding - Manual refresh

I recently discovered how nice it was to use DataBinding. I liked using it so much that I spent 4+ hours making it work for my application. In my application my data was being changed in the background by a continuously running thread. I suppose because it was being modified outside the scope of the form, the bindings were not being updated. It took me awhile to figure out how to manually refresh these binding.

The solution was to subscribe to the CurrentItemChanged event and then to run ReadValue() on all the controls Bindings. Here is the code that resulted.
private delegate void CurrentItemChangedCallback(object sender, EventArgs e);
private void BindingSource_CurrentItemChanged(object sender, EventArgs e)
{
if(InvokeRequired)
{
CurrentItemChangedCallback d = new CurrentItemChangedCallback(BindingSource_CurrentItemChanged);
this.Invoke(d, new object[] { sender, e });
}
else {
foreach (Binding b in myControl.DataBindings)
{
b.ReadValue();
}
}
}
The code only updates the myControl control, but it could have just as easily iterated through all the controls in the form and refreshed all their bindings as well.

Wednesday, November 01, 2006

XNA Beta 2

XNA Beta 2 just came out! Lucky for me I'm on my vacation. :-) Can't wait to look at what was added.

Sunday, October 29, 2006

Supreme Commander

Supreme Commander beta came out the other day. Hopefully I'll be able to get my hands on it soon. This will definitly be a must buy for me.

Tuesday, October 24, 2006

My first blog

I just wanted to try out this blogging stuff. Hopefully, this blog can serve as a gateway to share some information I collect during my journey through the software development world and life itself. Well, here's hoping!