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 ?

  1. BoltGridView = GridView()
  2. dropDownCell = Ansys.UI.Toolkit.GridViewDropDownCell()
  3. DropDownItems = []
  4. DropDownItems.append(GridViewDropDownCell.GridViewDropDownItem('Shank'))
  5. DropDownItems.append(GridViewDropDownCell.GridViewDropDownItem('Screw'))
  6. dropDownCell.AddItems(System.Array[GridViewDropDownCell.GridViewDropDownItem](DropDownItems))
  7. dropDownCell.Text = 'Shank'
  8. BoltGridView.Cells.SetCell(0, 0, dropDownCell)

Best Answer

  • 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

    1. def DropDownChanged(self, sender, args):
    2. text = args.Value
    3. Cell = args.Cell
    4. RowIndex = Cell.StartRowIndex
    5. CellType = Cell.GetType()
    6. if CellType == self.DropDownCell:
    7. ExtAPI.Log.WriteMessage('Here')
    8. if text == 'Shank':
    9. self.Cells[RowIndex ,3].Text = ''
    10. self.Cells[RowIndex, 3].BackColor = Ansys.Utilities.Palette.LightGray
    11. self.Cells[RowIndex, 3].ReadOnly = True
    12. elif text == 'Screw':
    13. self.Cells[RowIndex, 3].BackColor = Ansys.Utilities.Palette.White
    14. self.Cells[RowIndex, 3].ReadOnly = False

Answers

  • 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...

  • 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

    1. def DropDownChanged(self, sender, args):
    2. text = args.Value
    3. Cell = args.Cell
    4. CellType = Cell.GetType()
    5. if CellType == self.DropDownCell:
    6. # do something

Welcome!

It looks like you're new here. Sign in or register to get started.