oncheckedchanged

C# ASP.NET CheckBox_OnCheckedChanged not firing as expected

[亡魂溺海] 提交于 2019-12-11 10:14:21
问题 I have an issue with both Checkbox_OnCheckedChanged and Dropdownlist_OnSelectedIndexChanged events not triggering the relevant functions in my code behind. Both Controls are bound to values in a GridView . On the first OnCheckedChanged or OnSelectedIndexChanged event raised from the UI the functions in the code behind fire without error, however if I refresh my UpdatePanel , for example by changing the date range of the data inside the GridView and therefore loading more or less records, the

How to distinguish user vs programmatic changes in WinForms CheckBox?

自古美人都是妖i 提交于 2019-12-11 06:40:01
问题 I have logic on a CheckBox's OnCheckedChanged event that fires on form load as well as when user changes check state. I want the logic to only execute upon user action. Is there a slick way of detecting user vs programmatic change that doesn't rely on setting/checking user variables? 回答1: I usually have a bool flag on my form that I set to true before programmatically changing values. Then the event handler can check that flag to see if it is a user or programmatic. 回答2: Try some good old

Android 第十课——UI RadioButton

不想你离开。 提交于 2019-12-09 09:57:55
常用基础空组件 5 RadioGroup RadioButton 单选按钮时常用组件之一,但是开发过程中虽然很多地方会用到单选按钮,但是却不会用Android系统提供的原始样式,类似我们在写html时,不同的浏览器提供的单选按钮是不一样的,兼容性也很差,一般用图片替代伪装。但是无论如何伪装样式,单选按钮的功能都是一样的。下面就用一个 加减乘除 运算器来讲解单选按钮的功能,至于样式以后提供。 layout中组件: <RadioGroup android:id="@+id/operation" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <RadioButton android:id="@+id/addition" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="@string/addition"/> <RadioButton android:id="@+id/subtraction" android:layout_width="wrap

SwitchCompat OnCheckedChangeListener called on every orientation change of Fragment

半城伤御伤魂 提交于 2019-12-08 09:02:01
问题 I have an activity which hosts a fragment and the problem is that, on every orientation change and only if the switch was in the checked state, the OnCheckedChangeListener is called. How do I solve this problem? Thanks! MainActivity.java: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); if (savedInstanceState == null) { getSupportFragmentManager()

Clicking checkbox causes onCheckedChanged to fire twice

拥有回忆 提交于 2019-12-08 04:11:28
问题 I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time the sender parameter has a checkbox that is always checked=false. I am happy to entertain suggestions on other approached to solving this problem but my goal is to set a database

How to flip the checked status of a Switch only after confirm dialog?

你离开我真会死。 提交于 2019-12-07 21:55:12
问题 My problem is - when I click on a <Switch>, it gets toggled first and then the OnCheckedChangeListener is called. What I would like is this: <Switch> is clicked --> I show an AlertDialog --> If pressed yes or no --> Then flip ` with setChecked(boolean), [boolean = true if pressed yes, and false if pressed no]. Problem : When <Switch> is clicked, it gets flipped automatically. I want to qualify it with a yes or no from a AlertDialog first. sw_enableDisable .setOnCheckedChangeListener(new

Clicking checkbox causes onCheckedChanged to fire twice

依然范特西╮ 提交于 2019-12-07 01:00:32
I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time the sender parameter has a checkbox that is always checked=false. I am happy to entertain suggestions on other approached to solving this problem but my goal is to set a database flag based on the user checking a checkbox. I am targeting .NET Framework 2.0. Here is the associated

How to flip the checked status of a Switch only after confirm dialog?

我的梦境 提交于 2019-12-06 14:24:40
My problem is - when I click on a <Switch> , it gets toggled first and then the OnCheckedChangeListener is called. What I would like is this: <Switch> is clicked --> I show an AlertDialog --> If pressed yes or no --> Then flip ` with setChecked(boolean) , [boolean = true if pressed yes, and false if pressed no]. Problem : When <Switch> is clicked, it gets flipped automatically. I want to qualify it with a yes or no from a AlertDialog first. sw_enableDisable .setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean

Android: When using setOnCheckedChangeListener on switches I get 'Cannot Resolve Symbol Error'

帅比萌擦擦* 提交于 2019-12-04 11:01:49
package com.example.koustav.myapplication; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Switch; import android.widget.TextView; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } Switch swi = (Switch) findViewById(R.id.swch); swi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

How to disable checkbox when a limit is reached in android?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 21:37:27
I have 15 CheckBox and I must to stuck user when he checks more than 5. I use the method OnCheckedChangeListener to know if an item is checked, but I don't know how to limit after 5 items selected . See my code below: int lengthBox = 15; int lenghtCount = 0; // inside onCreate method final CheckBox[] checkbox = new CheckBox[lengthBox]; OnCheckedChangeListener checker = new OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton cb, boolean b) { // How can I improve this condition? if(checkbox[0].isChecked() || checkbox[1].isChecked() || checkbox[2].isChecked() ||