This is a migrated thread and some comments may be shown as answers.

Set RadCheckbox programmatically

1 Answer 335 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Bernhard
Top achievements
Rank 2
Bernhard asked on 30 Oct 2009, 10:39 PM

In our database tables we have a field isDeleted. This indicates if a record is logically deleted. 

There is a Delete-Button on the form. If the user presses this button, the flag should be set, then the data saved. After that the window is closed and the user gets back to the form with the list. The list is built upon a database view with the where-clause "where IsDeleted = 0".

For editing the data I have a detail data form with a ObjectView. On the form there is a RadCheckbox-Control named cbIsDeleted.
The control is bound via the IsChecked-Property to the persistent data.

  • If I check/uncheck the CheckBox with the mouse and save the data, the changed value is saved in the database.
  • If I want to do the same programmatically, on the GUI the Checkbox will be checked/ unchecked. But when I want to save the data - the changed value for the Checkbox wouldn't be stored in the database: 

 

 

cbIsDeleted.ToggleState =   
Telerik.WinControls.Enumerations.ToggleState.On; 

 

I tried also:

 

cbIsDeleted.Checked = true

What's wrong? Should I set some other properties?

Thanks in advance
Bernhard

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 04 Nov 2009, 02:15 PM
Hello Bernhard,

We use the mechanism of .net framework about Binding properties.

I tested your scenario with the following code snippet, and it seems that the checkbox is bound properly to the data table:

DataTable t;
 
private void Form6_Load(object sender, EventArgs e)
{
    this.radCheckBox1.IsThreeState = false;
     
    t = new DataTable();
    t.Columns.Add("A", typeof(bool));
 
    t.Rows.Add(true);
    t.Rows.Add(false);
    t.Rows.Add(true);
 
    this.radCheckBox1.DataBindings.Add(new Binding("IsChecked", t, "A"));
}

Checking and un-checking the checkbox affects the current row in the data table, and a change in the data table affects the checkbox.

Do not hesitate to write me back if you have further questions.

Greetings,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Bernhard
Top achievements
Rank 2
Answers by
Nick
Telerik team
Share this question
or