From b9d8ac3f9d91691effaa0477a8ba558e7c657f4f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 10 Dec 2016 14:26:22 +0800 Subject: [PATCH] fix column_cast doesn't ignore invisible column --- source/gui/widgets/listbox.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 596bf6be..a56001ad 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -437,16 +437,24 @@ namespace nana if (pos >= cont_.size()) throw std::out_of_range("listbox: invalid header index."); - if (disp_order) - return cont_[pos].index; - - size_type order = 0; + size_type order = 0; //order for display position for (auto & m : cont_) { - if (m.index == pos) - return order; + if (!m.visible_state) + continue; - ++order; + if (disp_order) + { + if (0 == pos) + return m.index; + ++pos; + } + else + { + if (m.index == pos) + return order; + ++order; + } } throw std::invalid_argument("listbox: invalid header index");