Update sizer after changing label of a wxStaticText

schmensch via wx-users <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
Hi,

I have a wxStaticText which Label can change at runtime. After this, the
sizers aren't updated. After a resize of the window, or minimising and
getting the window back, everything is fine.

I tested it with wxWidgets 3.2.4 and Windows 10. But it happens with
older wx versions too.

For demonstrating the problem, I've the following code which can be
copied in the minimal sample:


auto sizer = new wxBoxSizer(wxHORIZONTAL);

label = new wxStaticText(this, wxID_ANY, "test");

sizer->Add(label, 0, wxGROW);

auto input = new wxTextCtrl(this, wxID_ANY, "Init String",
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_RICH2);

sizer->Add(input, 0, wxGROW);

input->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent& evt)
      {
          label->SetLabel(evt.GetString());
          Update();
          Refresh();

      });

SetSizerAndFit(sizer);


It's just for demonstrating. When you enter a text, which is longer than
the old text in the text control, the label moves behind the textCtrl.

But, even when only resizing the window in vertical direction it
repaints the window and everything is fine.


Is there an other way to force a refresh of the window beside Update()
and Refresh()?

Best regards

Stefan

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/792d0cfb-f7a8-4430-b422-105c591434ee%40gmx.de.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.