Home Forums WinForms controls Xceed Grid for WinForms Add Radio Button to Xceed Grid.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16055 |

    hello,

     I want to add a seperate column to grid , in that column i want to put radio buttons , when i am select a radio button , that entire row need to be selected , when i am selecting another row radio button , the first radio button will be de-selected.

    Plz give entire code part (c#.net).

    Any body help to this.

     

    Thanks,

    sree.

    Imported from legacy forums. Posted by sree (had 824 views)

    Xceed Support
    Member
    Post count: 5658

    In this case, you will need to handle your own selection. Because, when you will click on an other row’s RadioButton, the GridControl’s selection will be lost. Here, I change the BackColor of the selected row to Red.

    //Sample code:

    public Form1()
    {
      InitializeComponent();
    }

    private void Form1_Load( object sender, EventArgs e )
    {
      Column col1 = new Column( “Column1” );
      Column col2 = new Column( “Column2” );
      Column col3 = new Column( “Column3” );
      Column col4 = new Column( “Column4”, typeof( bool ) );
      gridControl1.Columns.Add( col1 );
      gridControl1.Columns.Add( col2 );
      gridControl1.Columns.Add( col3 );
      gridControl1.Columns.Add( col4 );

      for( int i = 0; i < 20; i++ )
      {
        Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
        row.Cells[ 0 ].Value = “Item ” + i.ToString();
        row.Cells[ 1 ].Value = “Item ” + i.ToString();
        row.Cells[ 2 ].Value = “Item ” + i.ToString();
        row.Cells[ 3 ].Value = false;

        row.EndEdit();
      }
     
      RadioButton myRad = new RadioButton();
      RadioButton myRadEd = new RadioButton();
      gridControl1.Columns[ 3 ].CellViewerManager = new CellViewerManager( myRad, “Checked” );
      gridControl1.Columns[ 3 ].CellEditorManager = new CellEditorManager( myRadEd, “Checked”, true, true );
      gridControl1.Columns[ 3 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler( CellEditorManager_ActivatingControl );
      gridControl1.Columns[ 3 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler( CellEditorManager_DeactivatingControl );
    }

    void CellEditorManager_ActivatingControl( object sender, CellEditorEventArgs e )
    {
      ( ( RadioButton )e.Control ).CheckedChanged += new EventHandler( Form1_CheckedChanged );
    }

    void Form1_CheckedChanged( object sender, EventArgs e )
    {
      ( ( RadioButton )sender ).CheckedChanged -= new EventHandler( Form1_CheckedChanged );
      ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).EndEdit();
    }

    private int index = -1;

    void CellEditorManager_DeactivatingControl( object sender, CellEditorEventArgs e )
    {
      if( ( ( RadioButton )e.Control ).Checked )
      {
        if( index == -1 )
        {
          index = ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).Index;
          gridControl1.CurrentRow.BackColor = Color.Red;
        }
        else
        {
          gridControl1.DataRows[ index ].Cells[ 3 ].Value = false;
          gridControl1.DataRows[ index ].ResetBackColor();
          index = ( ( Xceed.Grid.DataRow )gridControl1.CurrentRow ).Index;
          gridControl1.CurrentRow.BackColor = Color.Red;
        }
      }
    }

    Imported from legacy forums. Posted by CharlesB (had 612 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you , it’s working.

    But we have clicked two times for selecting radio button.

    May i want, when clicked one time on that field that radio button need to be selected.

     

    Thanks,

    Sree.

    Imported from legacy forums. Posted by Srikanth (had 531 views)

    User (Old forums)
    Member
    Post count: 23064

        I have some data in Database , from stored procedure i get data from database and show in xceed grid.

       when select a row in xceed grid,  i want to put double click event for this situation.

       That means,  i want to select a row and double click on that row, i want to show some MessageBox or  Another UI.

       Plz help on this.

      Thanks,

      Sree.

      

    Imported from legacy forums. Posted by Srikanth (had 1761 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.