Devexpress - How to change the name of the button dynamically inside Datagridview

Asked

Viewed 31 times

0

Please, I need some help, I’m new in development c# widowsform.

I have a Datagridview that pushes some buttons for each line, I can’t program so that the name of the button "Button.Caption" changes dynamically as the values of the Total Positions are modified, both when loading Datagridview and also when the user edits the corresponding column cell and row.

For example:

Total Vacancies = 20 --> The button must display the description/caption "Generate Draw" Total Vacancies = 40 --> The button must keep its original description/caption "Enroll" Total Vacancies = 10 --> The button must display the description/caption "On hold"

I tried to implement a code that I in Devexpress, but when the value of Total Vacancies = 20, the buttons of the datagridviw are locked and the description appears three dots "..."

A) C# code applied to my Datagridview using the Customrowcelledit event

    private void bandedGridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
    {
        if (e.Column.Caption == "bandedGridColumn1")
        {
            int val = Convert.ToInt32(bandedGridView1.GetRowCellValue(e.RowHandle, "TOTALVAGAS"));
            if (val == 20)
            {
                RepositoryItemButtonEdit ritem = new RepositoryItemButtonEdit();
                ritem.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
                ritem.Buttons[0].Caption = "Gerar Sorteio";
                e.RepositoryItem = ritem; 

            }
        }
    }

B) Print form at runtime inserir a descrição da imagem aqui

Thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.