刚才看了一下listbox好像可以,但是放到摸板列中好像不能直接榜定

解决方案 »

  1.   

    会不会是你从数据库提取数据的Sql语句或者存储过程有问题?
      

  2.   

    你可以参考微软的例子:
    public class DataGridCRTextBoxColumn:DataGridTextBoxCellColumn
    {
    protected override object GetColumnValueAtRow(CurrencyManager source,int rowNum)
    {
    object val = base.GetColumnValueAtRow(source,rowNum);
    if( val.GetType() == Type.GetType("DBNull"))
    {
    return String.Empty; // string to display for DBNull
    }
    else
    {
    Decimal tmp = (Decimal)TypeDescriptor.GetConverter(Type.GetType("Decimal")).ConvertFrom(val);//.ConvertFromString(val.ToString());
    if(tmp>=0) 
    return tmp.ToString("0.00");
    else
    return (-tmp).ToString("0.00")+"CR";
    }
    }
    protected override bool Commit(CurrencyManager dataSource,int rowNum)
    {
    // parse the date and write to underlying record. base.HideEditBox();//return focus to the DataGrid control
    DataGridTextBox cell = base.TextBox as DataGridTextBox;
    Decimal val; // Do not write data if not editing. if( cell.IsInEditOrNavigateMode) return true;
    if( base.TextBox.Text == "")  // I map  ""  to DBNull
    base.SetColumnValueAtRow(dataSource,rowNum,DBNull.Value);
    else
    {
    try
    {
    if(base.TextBox.Text.ToUpper().EndsWith("CR"))
    val = - Decimal.Parse(base.TextBox.Text.Substring(0,base.TextBox.Text.Length-2));
    else
    val = Decimal.Parse(base.TextBox.Text); base.SetColumnValueAtRow(dataSource,rowNum,val); }
    catch
    {
    return false; // Exit on error and display old "good" value
    }
    } base.EndEdit(); // Let the DataGrid know that processing is completed.
    return true; // Success
    } }
      

  3.   

    我的意思是使用字典表,比如说这个表里只有用户的id而在datagrid中显示的时候要显示用户的姓名,在另一个表里有用户id和姓名字段
      

  4.   

    实际上是不是显示的Text和Value分别赋值,up
      

  5.   

    用sql写个就是了,select A.id,B.name where A.id=B.id
      

  6.   

    把原来绑定id那个列,改成绑定一个函数,传的参数是id。那个函数是会根据这个id去数据库里取出对应的名字,再把这个名字反回来,就可以了