GridViewDropDownCell SelectedChanged event

I add a GridViewDropDownCell in GridView, and I want to do something after the dropdowncell selectchanged. But I am not find the revelation event in GridView.
I have try to use AfterCellEdit event, but it seems to work before the dropdowncell text changed.
So I want to know is there any event after dropdowncell selectchanged ?

BoltGridView = GridView()
dropDownCell = Ansys.UI.Toolkit.GridViewDropDownCell()
DropDownItems = []
DropDownItems.append(GridViewDropDownCell.GridViewDropDownItem('Shank'))
DropDownItems.append(GridViewDropDownCell.GridViewDropDownItem('Screw'))
dropDownCell.AddItems(System.Array[GridViewDropDownCell.GridViewDropDownItem](DropDownItems))
dropDownCell.Text = 'Shank'
BoltGridView.Cells.SetCell(0, 0, dropDownCell)

Best Answer

  • 1990chs
    1990chs Member Posts: 46
    10 Comments First Anniversary Name Dropper
    **
    Answer ✓

    This is solved.
    From the args to get the StartRowIndex and type to do something after celledif

    def DropDownChanged(self, sender, args):
            text = args.Value
            Cell = args.Cell
            RowIndex = Cell.StartRowIndex
            CellType = Cell.GetType()
            if CellType == self.DropDownCell:
                ExtAPI.Log.WriteMessage('Here')
                if text == 'Shank':
                    self.Cells[RowIndex ,3].Text = ''
                    self.Cells[RowIndex, 3].BackColor = Ansys.Utilities.Palette.LightGray
                    self.Cells[RowIndex, 3].ReadOnly = True
                elif text == 'Screw':
                    self.Cells[RowIndex, 3].BackColor = Ansys.Utilities.Palette.White
                    self.Cells[RowIndex, 3].ReadOnly = False
    

Answers

  • Felix
    Felix Member Posts: 4
    Name Dropper First Comment
    **

    Hi @1990chs
    Have you found which event can be used with the gridviewdropdowncell?
    I'm struggling with that as well...

  • 1990chs
    1990chs Member Posts: 46
    10 Comments First Anniversary Name Dropper
    **
    edited July 2024

    @Felix said:
    Hi @1990chs
    Have you found which event can be used with the gridviewdropdowncell?
    I'm struggling with that as well...

    You can use AfterCellEdit event, then check if the cell type is gridviewdropdowncell, then do something.
    I don't find other event

    def DropDownChanged(self, sender, args):
            text = args.Value
            Cell = args.Cell
            CellType = Cell.GetType()
            if CellType == self.DropDownCell:
                # do something