Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Update Command Cell After Click

$
0
0
Problem:
What should be done to force the Command button to change its content right away, without changing the focus to other cell?

 

usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingTelerik.WinControls.UI;
 
namespaceGridApp
{
    publicpartialclassRadForm1 : Telerik.WinControls.UI.RadForm
    {
        publicRadForm1()
        {
            InitializeComponent();
            radGridView1.Rows.Add(newobject[1] { "zero"});
            radGridView1.Rows.Add(newobject[1] { "one"});
            radGridView1.Rows.Add(newobject[1] { "two"});
            radGridView1.Rows.Add(newobject[1] { "three"});
            radGridView1.Rows.Add(newobject[1] { "four"});
        }
 
        privatevoidradGridView1_CommandCellClick(objectsender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        {
            switch(e.ColumnIndex)
            {
                case1:
                    RadButtonElement b = (RadButtonElement)((GridCellElement)radGridView1.CurrentCell).Children[0];
                    b.Tag = true^ (bool)b.Tag;
                    break;
                default:
                    break;
            }
        }
 
        privatevoidradGridView1_CellFormatting(objectsender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        {
            if(e.ColumnIndex == 1)
            {
                RadButtonElement b = (RadButtonElement)e.CellElement.Children[0];
                b.ImageAlignment = ContentAlignment.MiddleCenter;
                b.TextAlignment = ContentAlignment.MiddleCenter;
                // set bool data as switch
                if(b.Tag == null) b.Tag = false;
                b.Text = ((bool)b.Tag) ? "locked": "open";
            }
        }
    }
}

 

 

 


Viewing all articles
Browse latest Browse all 78072

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>