知道选项值 怎样用VB将vb复选框选中事件对应的选项选中

jquery ztree checkbox 手动选中问题
[问题点数:40分,结帖人xiaowanzi80hou]
jquery ztree checkbox 手动选中问题
[问题点数:40分,结帖人xiaowanzi80hou]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
本帖子已过去太久远了,不再提供回复功能。我说的可不是截图方式,是想在软件运行时如何获取系统CheckBox的三种样式图。比如在xp系统上运行时获取的是绿色的钩与绿色的填充块(半选),在win&7中图形就变了,所以我想以程序方式获取。当然是用在自定义控件上,为的是跟系统样式保持一致。
回复讨论(解决方案)
获取不到……
控件的外观应该是自动的吧,同一个EXE,运行在不同系统下他的外观默认是和系统一致的。
要不然你打开工程属性,里面有一个“启用XP视觉样式”的复选框,你改一下这个项目试试。
Good&luck!!!
是不是没办法通过CheckBox控件的程序集信息获取出里面所使用的三种状态的图片啊?
是不是没办法通过CheckBox控件的程序集信息获取出里面所使用的三种状态的图片啊?
你说了是随系统改变样式的,那么图片什么的就不会在程序集中。
如果是WPF程序,可以用VisualBrush获取到,不过我猜你这是WinForm的
没错是winform的。那么说比如CheckBox控件的那个小box,是checkbox控件本身的资源图片吗?还是绘制的结果?是win7和xp系统本身的checkbox就不是同一个吗?如何能做到我的自定义控件的Box与系统CheckBox的保持一致呢?肯定不是用图片了,图片就限定死了。
没错是winform的。那么说比如CheckBox控件的那个小box,是checkbox控件本身的资源图片吗?还是绘制的结果?是win7和xp系统本身的checkbox就不是同一个吗?如何能做到我的自定义控件的Box与系统CheckBox的保持一致呢?肯定不是用图片了,图片就限定死了。
你自定义控件的box用checkbox的就可以和系统的一样了啊
其实我是做了个三态treeview,用自己的想法实现的,各级间动态关联。没有使用Treeview的box,而是通过StateImageKey实现的。我知道如果使用系统控件会一致。可这里使用的图片,无法利用上控件阿。所以我才想能不能读出控件图片来。
要么我的方案就得改了。其实现在的也能用,只是从完美思想上觉得换了系统,不与系统的一致很别扭。
其实我是做了个三态treeview,用自己的想法实现的,各级间动态关联。没有使用Treeview的box,而是通过StateImageKey实现的。我知道如果使用系统控件会一致。可这里使用的图片,无法利用上控件阿。所以我才想能不能读出控件图片来。
要么我的方案就得改了。其实现在的也能用,只是从完美思想上觉得换了系统,不与系统的一致很别扭。
你可以做成完全不与XP//VISTA/7一样的图片效果,这样在任何系统上都不会有别扭的感觉了。
是啊,看来这个问题也就这样了.Android中ListView结合CheckBox判断选中项 - 开源中国社区
当前访客身份:游客 [
当前位置:
本文主要实现在自定义的ListView布局中加入CheckBox控件,通过判断用户是否选中CheckBox来对ListView的选中项进行相应的操作。通过一个Demo来展示该功能,选中ListView中的某一项,然后点击Button按钮来显示选中了哪些项。
[1] 程序结构图如下:
其中Person.java是实体类,MainActivity.java是Activity组件类。listitem.xml是自定义的列表每项布局文件。
[2] listitem.xml布局文件源码如下:
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout
xmlns:android=&/apk/res/android&
android:orientation=&vertical&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&&
&LinearLayout
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:orientation=&horizontal&
android:descendantFocusability=&blocksDescendants&&
android:id=&@+id/list.select&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&/&
android:id=&@+id/list.name&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:layout_weight=&1&
android:text=&Name&
android:layout_gravity=&center&
android:textSize=&20dp&
android:layout_marginLeft=&10dp&/&
android:id=&@+id/list.address&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:layout_weight=&1&
android:text=&Address&
android:layout_gravity=&center&
android:textSize=&20dp&/&
&/LinearLayout&
&/LinearLayout&
[3] main.xml布局文件源码如下:
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout xmlns:android=&/apk/res/android&
android:orientation=&vertical&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&&
android:id=&@+id/show&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:text=&Show&/&
android:id=&@+id/lvperson&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&/&
&/LinearLayout&
[4] Person.java实体类源码如下:
package com.andyidea.
public class Person {
public String getName() {
public void setName(String name) {
this.name =
public String getAddress() {
public void setAddress(String address) {
this.address =
[5] MainActivity.java类源码如下:
package com.andyidea.
import java.util.ArrayL
import java.util.HashM
import java.util.L
import com.andyidea.bean.P
import android.app.A
import android.app.AlertD
import android.content.C
import android.os.B
import android.util.L
import android.view.LayoutI
import android.view.V
import android.view.ViewG
import android.widget.BaseA
import android.widget.B
import android.widget.CheckB
import android.widget.ListV
import android.widget.TextV
public class MainActivity extends Activity {
List&Person& persons = new ArrayList&Person&();
Context mC
List&Integer& listItemID = new ArrayList&Integer&();
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mContext = getApplicationContext();
show = (Button)findViewById(R.id.show);
lv = (ListView)findViewById(R.id.lvperson);
initPersonData();
adapter = new MyListAdapter(persons);
lv.setAdapter(adapter);
show.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
listItemID.clear();
for(int i=0;i&adapter.mChecked.size();i++){
if(adapter.mChecked.get(i)){
listItemID.add(i);
if(listItemID.size()==0){
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
builder1.setMessage(&没有选中任何记录&);
builder1.show();
StringBuilder sb = new StringBuilder();
for(int i=0;i&listItemID.size();i++){
sb.append(&ItemID=&+listItemID.get(i)+& . &);
AlertDialog.Builder builder2 = new AlertDialog.Builder(MainActivity.this);
builder2.setMessage(sb.toString());
builder2.show();
* 模拟数据
private void initPersonData(){
for(int i=1;i&=12;i++){
mPerson = new Person();
mPerson.setName(&Andy&+i);
mPerson.setAddress(&GuangZhou&+i);
persons.add(mPerson);
//自定义ListView适配器
class MyListAdapter extends BaseAdapter{
List&Boolean& mC
List&Person& listP
HashMap&Integer,View& map = new HashMap&Integer,View&();
public MyListAdapter(List&Person& list){
listPerson = new ArrayList&Person&();
listPerson =
mChecked = new ArrayList&Boolean&();
for(int i=0;i&list.size();i++){
mChecked.add(false);
public int getCount() {
return listPerson.size();
public Object getItem(int position) {
return listPerson.get(position);
public long getItemId(int position) {
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder =
if (map.get(position) == null) {
Log.e(&MainActivity&,&position1 = &+position);
LayoutInflater mInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = mInflater.inflate(R.layout.listitem, null);
holder = new ViewHolder();
holder.selected = (CheckBox)view.findViewById(R.id.list_select);
holder.name = (TextView)view.findViewById(R.id.list_name);
holder.address = (TextView)view.findViewById(R.id.list_address);
final int p =
map.put(position, view);
holder.selected.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox)v;
mChecked.set(p, cb.isChecked());
view.setTag(holder);
Log.e(&MainActivity&,&position2 = &+position);
view = map.get(position);
holder = (ViewHolder)view.getTag();
holder.selected.setChecked(mChecked.get(position));
holder.name.setText(listPerson.get(position).getName());
holder.address.setText(listPerson.get(position).getAddress());
static class ViewHolder{
[6] 程序运行后的结果如下:
文章出处:
共有12个评论
<span class="a_vote_num" id="a_vote_num_
好东西,顶一个
<span class="a_vote_num" id="a_vote_num_
的确是好东西,但是如何通过在最外面定义一个CheckBox,点击该CheckBox,一下可以选中ListView每行的所有CheckBox呢?请问博主有没考虑过该问题啊——一键选中
--- 共有 1 条评论 ---
这个我也试过,要用到父控件(checkBox)和子控件(checkBox)之间的逻辑关系~大神可以有简单的实现方法吗?
(2年前)&nbsp&
<span class="a_vote_num" id="a_vote_num_
<span class="a_vote_num" id="a_vote_num_
应该通过position点击的哪一行
<span class="a_vote_num" id="a_vote_num_
引用来自“loveandroid”的答案的确是好东西,但是如何通过在最外面定义一个CheckBox,点击该CheckBox,一下可以选中ListView每行的所有CheckBox呢?请问博主有没考虑过该问题啊——一键选中可以通过position来确认吧
<span class="a_vote_num" id="a_vote_num_
<span class="a_vote_num" id="a_vote_num_
<span class="a_vote_num" id="a_vote_num_
<span class="a_vote_num" id="a_vote_num_
可以在自定义的构造函数中把外部checkbox传进来不就可以实现了
<span class="a_vote_num" id="a_vote_num_
更多开发者职位上
有什么技术问题吗?
鉴客的其它问题
类似的话题在VB中如果用几个checkbox控件,请问怎么样才能使几个控件中只要一个被选中了,其他就不能被选中呢?
在VB中如果用几个checkbox控件,请问怎么样才能使几个控件中只要一个被选中了,其他就不能被选中呢?
最好把几个控件组成一个控件数组,这样比较好处理。下面是代码(Check1):&
&&&&Private&Sub&Check1_Click(Index&As&Integer)&
&&&&&Dim&i&As&Integer
&&&&&If&Check1(Index).Value&=&Checked&Then&
&&&&&&&&For&i&=&0&To&Check1.Count&-&1&
&&&&&&&&&&&&If&i&&&&Index&Then&Check1(i)&=&Unchecked&
&&&&&&&&Next&i&
&&&&&End&If&
&&&&End&Sub
发表评论:
TA的最新馆藏[转]&[转]&[转]&}

我要回帖

更多关于 获取复选框选中的值 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信