简体   繁体   English

DevExpress VerticalGrid 行属性

[英]DevExpress VerticalGrid Row properties

I use DevExpress 22 .我使用DevExpress 22 I add an EditorRow to the VerticalGrid .我将EditorRow添加到VerticalGrid In EditorRow properties for RowEdit selected LookUpEdit from In-place Editor repository .EditorRowRowEdit属性中,从In-place Editor repository中选择了LookUpEdit LookUpEdit contains a list from the database with color names. LookUpEdit包含来自数据库的带有颜色名称的列表。 when I select a color name from the list, the EditorRow is painted in that color.当我从列表中输入 select 颜色名称时, EditorRow被涂成该颜色。 but, when I select a color from the list, it is not applied immediately, only when I remove the focus from the EditorRow .但是,当我 select 从列表中选择一种颜色时,它不会立即应用,只有当我从EditorRow中移除焦点时才会应用。 I use EditValueChanged to handle selecting value from a list:我使用EditValueChanged来处理从列表中选择值:

private void Ilue_zprstatus_EditValueChanged(object sender, EventArgs e)
{
    LookUpEdit ilue = sender as LookUpEdit;
    
    if (ilue.EditValue.ToString() == "Green")
    {                                
        zpr_status.AppearanceCell.BackColor = Color.FromArgb(0x99, 0xFF, 0x99);               
    }              
    if (ilue.EditValue.ToString() == "Yellow")
    {               
        zpr_status.AppearanceCell.BackColor = Color.FromArgb(0xFF, 0xFF, 0x99);
    }
    if (ilue.EditValue.ToString() == "White")
    {
        zpr_status.AppearanceCell.BackColor = Color.FromArgb(0xFF, 0xFF, 0xFF);          
    }            
}

the function works, but the color does not change immediately. function 有效,但颜色不会立即改变。 Questions:问题:

  1. How to refresh the EditorRow state immediately after selecting a value from the list?如何在从列表中选择一个值后立即刷新EditorRow state?
  2. How to get in EditorRow the value of DisplayMember from LookUpEdit instead of ValueMember ?如何在EditorRow中从LookUpEdit而不是ValueMember获取DisplayMember的值?

You should handle the lookup repository item's EditValueChanged event.您应该处理查找存储库项的EditValueChanged事件。 See the following code sample:请参阅以下代码示例:

public Form1() {
    InitializeComponent();
    vGridControl1.DataSource = ColorRecord.Init();
    vGridControl1.ForceInitialize();
    RepositoryItemLookUpEdit lookupColor = new RepositoryItemLookUpEdit();            
    lookupColor.ValueMember = "Color"; // Type - Color
    lookupColor.DisplayMember = "ColorName"; // Type - String
    lookupColor.EditValueChanged += new EventHandler(loolupColor_EditValueChanged);
    vGridControl1.Rows["Color"].Properties.RowEdit = lookupColor; // Type - Color
}
// Fires once you selected a values from the dropdown list.
void loolupColor_EditValueChanged(object sender, EventArgs e) {
    // Gets the lookup's value.
    Color selectedColor = (Color)(sender as LookUpEdit).EditValue;
    // Gets the lookup's display text.
    string colorName = (sender as LookUpEdit).Text;
    // Posts the selected value to the vGrid's data source.
    vGridControl1.PostEditor();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM