CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

John Papa [MVP C#]

.NET Code Samples, Data Access, and Other Musings

July 2005 - Posts

  • BlogJet Needs Some Work

    A while back I blogged about my first impressions of BlogJet. While I've been using BlogJet on and off for a few months, I have unfortunatley put it back on my shelf. Don't get me wrong, it shows some real promise, but I had more issues with it not uploading images properly and sending some of my new posts into the netherworld. That is my biggest issue with BlogJet. I gave this a long hard look because I really wanted it to work. In any event, I will be sending some of my concerns to them as well as some of my future requests for features such as built in code formatting for code samples. (Currently I use a custom program I wrote as well as a program called CopySourceAsHtml for formatting code.)

    For now I am using an HTML editor and good old copy and paste.

    NOTE: Brendan recently pointed out that it might be our server which is causing the uploading issues. So I apologize to the BlogJet software for any ill will :-) Seriously though, I still wish it had code formatting built in. How awesome would that be!

     

    Posted Jul 29 2005, 03:12 PM by John Papa with 4 comment(s)
    Filed under:
  • Custom Tooltips in WinForm TreeViews

    This is one of those simple coding issues that I was recently faced with that I wish I had a simple example to show me how to knock this out. I had to create a treeview whose nodes were supposed to display a tooltip that could change based on the selected node. Pretty straightforward issue overall, but I ran into a problem: the tooltips weren't working. OK, so it was a big problem with a simple solution. Long story short, there are a few key ingredients in setting tooltips that change based on the node you have selected. My problem stemmed from forgetting to deactivate the tooltip and then reactivate it. I did not see this anywhere in the documentation but I stumbled across it by trying different properties out. Now, maybe this is common knowledge to some or even most of you, but to me it sure wasn't. But I have run into controls in the past that needed to be turned off and on to work properly. So I guess I just chalk this up as one more.

    Anyway, here is a short list of things to look for:

    • drag a tooltip control onto your designer that has the treeview control
    • create a mousemove event handler on the treeview to kick off the tooltip
    • check to make sure that a node is selected, or get out
    • check to make sure a different node is selected than previously, or get out
    • Make the tooltip deactive (tip.Active = false;)
    • Set the tooltip text (tip.SetTooltip(tree, toolTipText);
    • Make the tooltip active (tip.Active = true;)

    Now, I had an object stored in the tag of each treeview node. So I grab it, figure out which obejct I have and get a property of the object to use for the tooltip. This part is up to your implementation of course.

     

    Tooltips
    
    private void tree_MouseMove(object sender, 
    	System.Windows.Forms.MouseEventArgs e)
    {
    	TreeNode currentNode = tree.GetNodeAt(e.X, e.Y);
    
    	if ((currentNode == null) 
    		|| (previousNode == currentNode) || (currentNode.Tag == null))
    		return;
    
    	string toolTipText = string.Empty;
    
    	previousNode = currentNode;
    
    	object o = previousNode.Tag;
    
    	if (o is Class1)
    		toolTipText = Class1.Description;
    	else if (o is Class2)
    		toolTipText = Class2.Description;
    	else if (o is Class3)
    		toolTipText = Class3.Description;
    	else
    		toolTipText = string.Empty;
    
    	// Turn off the tooltip so we can change the text
    	if (tip.Active)
    		tip.Active = false;
    
    	// Change the tooltip text
    	tip.SetToolTip(tree, toolTipText);
    
    	// Turn on the tooltip 
    	tip.Active = true;
    }
    
    

    Posted Jul 23 2005, 12:31 AM by John Papa with 2 comment(s)
    Filed under:
  • Enterprise Library's Data Access Application Block - Part 2

    In the August 2005 issue of MSDN Magazine I continued my discussion of the Enterprise Library’s Data Access Application Block. This is part 2 in a 3 part series where I explore the Enterprise Library DAAB in my Data Points column. I had a lot of good feedback from part 1, which I will try to answer in my blog and possibly in a future follow up article. I have been surprised at how many people are so interested in Ent Lib in general. Its not a solution for everything, but it certainly does have great value and the development community appears to be very interested in it.

    You can read the article online here. If you want to read Part 1 first, you can catch that online here.

  • The Important Things in Life

    I’ve been pretty absent from the blogging scene of late. Life can throw you many twists and turns and many of them are when they are least convenient or least expected. My family has had one of these thrown at us recently and I am thankful for God and my family for being here for me and for each other to help us through.

    Like many people around the world, my family has been dealing with an immediate family member battling cancer. I am blessed to have a large and loving family with whom I am very close. We are helping each other through this as well as we can as it is always difficult dealing with our mortality. Cancer has a way of breaking down the person that you know physically and the medications have a way of breaking them down mentally. In some ways you wish they could not be on medication so they could live out what they have left without the inconvenience of 20 pills a day that mess with your mind and body. In a more selfish sense, I sometimes wish that the pills will continue so I can enjoy my family member for as long as possible. These and a lot of other thoughts go through your head when you are faced with such dire situations.

    I am thankful for the time I have had and the future time I will have with my family. I thank God for blessing us with all that we have. I cherish the times that remain and will regret nothing. I love my family and God as they all have been very good to me.

    Recently I have been trying to explain to one of my young children why our family member is sick. What that means, in terms she can understand. That is a difficult conversation I had hoped she was too young to have. But she surprised me in that she was ready to talk about it. Willing. Wanted to talk about it. Sometimes people get sick and their time on earth will end soon. It makes us sad, but it is also a good thing as God is calling us home to heaven. We should cherish our family and our loved ones. Discussing this sometimes complicated situation with my daughter helped me put it into perspective that while this is still a sad time, that it is important to cherish all that we have before it is gone. Have no regrets in life. Play with your children, kiss your spouse, tell them that you love them. Call your sister whom you haven’t seen nor talked to in years. Visit your elderly relatives.

    I am certainly no saint, in fact I imagine that I have sinned more than my share. Sometimes it just helps to get these things down in writing. I am thankful that I am finally beginning to understand these things.

    NOTE: This blog won’t appear in the main feed of our blog since its content is obviously not technology related.

More Posts