TestStack / White

DEPRECATED - no longer actively maintained
Other
1.02k stars 485 forks source link

DataGridView in WinForms: Select() not working #73

Open jalla347 opened 11 years ago

jalla347 commented 11 years ago

Hi,

I have a DataGridView in a WinForms application. When i use the Select() method on a row, nothing happens.

It works okay in the application itself, so there is something wrong in White.

Furthermore, why is there no IsSelected property on the row class for the datagridview?

JakeGinnivan commented 11 years ago

Could you extend the datagridview tests in White to include your failing scenario and I can then fix it.

jalla347 commented 11 years ago

It looks like the problem is that the Select() method assumes that there is a TableRowHeader. If it is not, then it will just return false.

Anyway -- how is multi select supposed to work here? I have a datagridview in WinForms where I have to select multiple rows. I can do that by using CTRL + clicking, but that might not be so nice?

    public virtual bool Select()
    {
        actionListener.ActionPerforming(this);
        TableRowHeader header = Header;
        if (header != null)
        {
            header.Click();
        }

        return header != null;
    }
ritro commented 11 years ago

Actually this Select method was supposed to imitate the clicking the left header (the collumn with arrows) I think (as many other methods in White which just imitate user actions - like adding text to textfield). So it's ok for this method to check for the header. Simple click on the row selects the cell, not the row, and Ctrl+Click selects the additional cells not rows for me. So either select row by selecting all cells in the row either have a row header. If you have a hotkey to select row without it - imitate pressing this hotkey. Hope this helps.