Showing posts with label mouseover. Show all posts
Showing posts with label mouseover. Show all posts

Monday, January 10, 2011

GridView Row Highlighting on Mouseover

spgv.RowCreated += new GridViewRowEventHandler(spgv_RowCreated);


void spgv_RowCreated(object sender, GridViewRowEventArgs e)
        {
            // only apply changes if its DataRow
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // when mouse is over the row, save original color to new attribute, and change it to highlight yellow color
                e.Row.Attributes.Add("onmouseover",
              "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEEEEE';this.style.cursor='pointer'");


                // when mouse leaves the row, change the bg color to its original value   
                e.Row.Attributes.Add("onmouseout",
                "this.style.backgroundColor=this.originalstyle;this.style.cursor='default'");
                 
                // on click row, go to item detail
                e.Row.Attributes.Add("onclick", "javascript:location.href='" + ((DataRowView)e.Row.DataItem).Row.ItemArray.GetValue(6) + "'");
            }
        }

Sunday, March 21, 2010

Sliding Javascript Menu using JQuery

Slide and fade in while mouseover
$("#Header").hover(function() {
$("#Menu").animate({ opacity: "show", height: "show" }, 800);
});

Slide and fade out after a specified time out
$("#Menu").mouseleave(function() {
setTimeout(function() {
$("#Menu").animate({ opacity: "hide", height: "hide" }, 900);
}, 1000);
});

Wednesday, December 16, 2009

Continue scrolling while mouseover - Silverlight

Context: While mouse cursor is over an object (i.e. button, image, canvas), a function should continue to occur. This is useful for continuous horizontal scrolling of menu items.

The idea is to declare two DispatcherTimer objects (one for each direction of scrolling). You can set the interval of the timer objects accordingly. The Tick property defines the method that the timer calls at each interval.


private System.Windows.Threading.DispatcherTimer _ScrollUpDispatcherTimer;
private System.Windows.Threading.DispatcherTimer _ScrolDownDispatcherTimer;

private void bNext_MouseEnter(object sender, MouseEventArgs e)
{
_ScrolDownDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
_ScrolDownDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 300);
_ScrolDownDispatcherTimer.Tick += new EventHandler(ScrollDown_Each_Tick);
_ScrolDownDispatcherTimer.Start();
}
private void bPrev_MouseEnter(object sender, MouseEventArgs e)
{
_ScrollUpDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
_ScrollUpDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 300);
_ScrollUpDispatcherTimer.Tick += new EventHandler(ScrollUp_Each_Tick);
_ScrollUpDispatcherTimer.Start();
}

public void ScrollUp_Each_Tick(object o, EventArgs sender)
{
//scroll-up function
}
public void ScrollDown_Each_Tick(object o, EventArgs sender)
{
//scroll-down function
}

private void bPrev_MouseLeave(object sender, MouseEventArgs e)
{
_ScrollUpDispatcherTimer.Stop();
}
private void bNext_MouseLeave(object sender, MouseEventArgs e)
{
_ScrolDownDispatcherTimer.Stop();
}

Remember to call the respective stop() functions in the scrolling functions if there is nothing more to scroll.