我的宏有问题。我知道它的很多代码(sry),但我认为它可能会有所帮助。所以我想要做的基本事情是,获取组合框的值并在另一个工作表中搜索它以获得在下一列中写入的价格。 到目前为止很容易,但我搜索的名称在数据库中并不是唯一的。我正在寻找的只是通过正确命名范围的一部分来定义(即EngineMercedesDiesel)
public class NuovoAdapter extends BaseAdapter {
private LayoutInflater layoutinflater;
private Context context;
ArrayList<HashMap<String, String>> dataList;
ArrayList<HashMap<String,String>> list_selected;
boolean [] itemChecked;
boolean[] checkBoxState;
public NuovoAdapter(Context context, ArrayList<HashMap<String, String>> list_serv) {
super();
this.context = context;
this.dataList = list_serv;
itemChecked = new boolean [dataList.size()];
list_selected = new ArrayList<HashMap<String, String>>();
checkBoxState=new boolean[dataList.size()];
list_selected.clear();
}
@Override
public int getCount() {
return dataList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = inflater.inflate(R.layout.prenota_serv, null);
holder = new ViewHolder();
holder.id = (TextView) convertView.findViewById(R.id.et_id);
holder.service = (TextView) convertView.findViewById(R.id.et_serv);
holder.costo = (TextView) convertView.findViewById(R.id.et_costo);
holder.durata = (TextView) convertView.findViewById(R.id.et_dur);
holder.Ceck = (CheckBox) convertView.findViewById(R.id.checkBox);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.id.setText(dataList.get(position).get("ID"));
holder.service.setText(dataList.get(position).get("Descrizione"));
holder.costo.setText(dataList.get(position).get("Costo"));
holder.durata.setText(dataList.get(position).get("Durata_m"));
//holder.Ceck.setChecked(false);
holder.Ceck.setChecked(checkBoxState[position]);
holder.Ceck.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(((CheckBox)v).isChecked())
checkBoxState[position]=true;
else
checkBoxState[position]=false;
}
});
holder.Ceck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
HashMap<String, String> data = dataList.get(position);
if (isChecked) {
addToSelected(data);
} else {
removeSelected(data);
}
}
});
return convertView;
}
private void addToSelected(HashMap contact){
if(!list_selected.contains(contact))list_selected.add(contact);
}
private boolean removeSelected(HashMap contact){
return list_selected.remove(contact);
}
public ArrayList<HashMap<String, String>> getSelectedItems(){
return list_selected;
}
}
class ViewHolder {
TextView id;
TextView service;
TextView costo;
TextView durata;
CheckBox Ceck;
}
我跳,你可以帮助我,(希望)你有一个简单的答案
答案 0 :(得分:0)
好吧我终于做到了!
ElseIf checkboxmech.Value = True Then
c = checkboxmech.Caption
mname = teil & hersteller & c
Set go = Worksheets("Gruppendatenbank").Range(mname)
Tabelle3.Range("C4").Value = getprice(go, handle)
将mname定义为variant数据类型并定义我的范围的工作表是非常重要的。 感谢您的帮助
statusupdate:已解决!