我用的是以下语句:
XtraGrid1.Properties.GetDataSourceRowByKeyValue("[email protected]")如果data source中的key value = "[email protected]",这句话就返回null,说没找到。请问,如何作才能忽略大小写?
急!
XtraGrid1.Properties.GetDataSourceRowByKeyValue("[email protected]")如果data source中的key value = "[email protected]",这句话就返回null,说没找到。请问,如何作才能忽略大小写?
急!
谢谢 liujia_0421(SnowLover) 还有没有其他办法?另一种思路是,是否可以由其他方法代替 GetDataSourceRowByKeyValue??我只要求能够按照某个值查找到匹配的项,忽略大小写就行了。
通过数据库的自己定义的一个主键与条件,然后你就在条件与主键(变成大写).
下在是实现的代码,呵呵这个我刚前天使用到。
/// <summary>
/// 表格的行查找
/// </summary>
/// <param name="_col">列头字段</param>
/// <param name="_locatevalue">列头字段值</param>
/// <returns></returns>
private bool Locate(int _col,string _locatevalue,DataSet AppDs)
{
int i = 0;
foreach(DataRow dr in AppDs.Tables[0].Rows)
{
string _tmp = dr[_col].ToString().Trim();
if (_tmp.ToUpper==_locatevalue.ToUpper)
{
this.gridControl.CurrentRowIndex = i;
this.gridControl.Select(i);
this.gridControl.CurrentCell = new DataGridCell(i,3);
return true;
}
i++;
}
this.gridControl.CurrentRowIndex =0;
this.gridControl.Select(0);
return false;
}
public virtual int FindValueIndex(string propName, object obj, int indexFrom) {
if(ItemCount == 0) return -1;
if(indexFrom < 0) indexFrom = 0;
if(propName != string.Empty)
obj = ConvertValue(obj, propName);
for(int i = indexFrom; i < ItemCount; i++) {
object record = GetListSourceRow(i);
if(ObjectsEqual(obj, GetValueAtIndex(propName, i)))
return i;
}
return -1;
}