c#如何获取comboBox当前选中的值
我更改comboBox1选项框的值后,但是comboBox1.SelectedItem.ToString();的值并没有更改,一直都是语文,不及格名单后面的输出就是名字和...
我更改 comboBox1选项框的值后,但是comboBox1.SelectedItem.ToString();的值并没有更改,一直都是语文,不及格名单后面的输出就是名字和选项框的值,我已经改成 “数学” 了,输出的还是 “语文”;
展开
展开全部
1.添加combobox后做如下设置
2.根据自己的需要在类中重写如下方法
// ==========================================================
// Combo box data source methods
// ==========================================================
- (NSInteger) numberOfItemsInComboBox: (NSComboBox *) aComboBox {
#pragma unused (aComboBox)
return ([dataSource count]);
}
- (id) comboBox: (NSComboBox *) aComboBox objectValueForItemAtIndex: (NSInteger) index {
#pragma unused (aComboBox)
return [dataSource objectAtIndex:index];
}
- (NSUInteger) comboBox: (NSComboBox *) aComboBox indexOfItemWithStringValue: (NSString *) string {
#pragma unused (aComboBox)
return [dataSource indexOfObject:string];
}
- (NSString *) firstGenreMatchingPrefix: (NSString *) prefix {
NSString *string = nil;
NSString *lowercasePrefix = [prefix lowercaseString];
NSEnumerator *stringEnum = [dataSource objectEnumerator];
while ( string = [stringEnum nextObject] )
if ([[string lowercaseString] hasPrefix:lowercasePrefix] ) {
return (string) ;
}
return (nil);
} // firstGenreMatchingPrefix
- (NSString *) comboBox: (NSComboBox *) aComboBox completedString: (NSString *) inputString {
#pragma unused (aComboBox)
// This method is received after each character typed by the user, because we have checked the "completes" flag for
// genreComboBox in IB.
// Given the inputString the user has typed, see if we can find a genre with the prefix, and return it as the suggested complete
// string.
NSString *candidate = [self firstGenreMatchingPrefix:inputString];
return (candidate ? candidate : inputString);
}
这些方法实现combobox在选择选项、自动完成时的处理方式。其中dataSource为NSArray。
3.设置combobox的datasource为实现上述方法的对象即可。
2.根据自己的需要在类中重写如下方法
// ==========================================================
// Combo box data source methods
// ==========================================================
- (NSInteger) numberOfItemsInComboBox: (NSComboBox *) aComboBox {
#pragma unused (aComboBox)
return ([dataSource count]);
}
- (id) comboBox: (NSComboBox *) aComboBox objectValueForItemAtIndex: (NSInteger) index {
#pragma unused (aComboBox)
return [dataSource objectAtIndex:index];
}
- (NSUInteger) comboBox: (NSComboBox *) aComboBox indexOfItemWithStringValue: (NSString *) string {
#pragma unused (aComboBox)
return [dataSource indexOfObject:string];
}
- (NSString *) firstGenreMatchingPrefix: (NSString *) prefix {
NSString *string = nil;
NSString *lowercasePrefix = [prefix lowercaseString];
NSEnumerator *stringEnum = [dataSource objectEnumerator];
while ( string = [stringEnum nextObject] )
if ([[string lowercaseString] hasPrefix:lowercasePrefix] ) {
return (string) ;
}
return (nil);
} // firstGenreMatchingPrefix
- (NSString *) comboBox: (NSComboBox *) aComboBox completedString: (NSString *) inputString {
#pragma unused (aComboBox)
// This method is received after each character typed by the user, because we have checked the "completes" flag for
// genreComboBox in IB.
// Given the inputString the user has typed, see if we can find a genre with the prefix, and return it as the suggested complete
// string.
NSString *candidate = [self firstGenreMatchingPrefix:inputString];
return (candidate ? candidate : inputString);
}
这些方法实现combobox在选择选项、自动完成时的处理方式。其中dataSource为NSArray。
3.设置combobox的datasource为实现上述方法的对象即可。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
onSelect:function(rec){varval=$('#cc1').combobox('getValues').join(',');$('#OperationID').val(val);}这样可以多选,用一个文本框解决后台取值问题,后台直接取值的话,跟你一样问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
DataRowView drv = (DataRowView)comboBox1.SelectedItem;
string Id = drv.Row["id"].ToString();
string Id = drv.Row["id"].ToString();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询