Click here to Skip to main content
15,867,835 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionListBox does not update when DataSource is changed Pin
rbsbscrp17-May-13 5:36
rbsbscrp17-May-13 5:36 
AnswerRe: ListBox does not update when DataSource is changed Pin
rbsbscrp17-May-13 6:59
rbsbscrp17-May-13 6:59 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen24-May-13 2:59
professionalEddy Vluggen24-May-13 2:59 
GeneralRe: ListBox does not update when DataSource is changed Pin
Dave Kreskowiak24-May-13 5:23
mveDave Kreskowiak24-May-13 5:23 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp24-May-13 20:03
rbsbscrp24-May-13 20:03 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen24-May-13 23:03
professionalEddy Vluggen24-May-13 23:03 
GeneralRe: ListBox does not update when DataSource is changed Pin
Dave Kreskowiak25-May-13 3:55
mveDave Kreskowiak25-May-13 3:55 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp30-May-13 14:16
rbsbscrp30-May-13 14:16 
Wow! You have such a myopic view of what's going on.


I don't think so. Let's revisit this one more time.

So I'm supposed to put all code that modifies a control into wrapper code that calls invoke and this wrapper code ends up being a conditional test to see if invoke is required and then recursively calling the same function thru a special delegate that is created just for that invoke call. I've repeated my example code below:

C#
private delegate void RefreshLbxDg8();
private RefreshLbxDg8 _refreshLbx;
...
_refreshLbx = RefreshLbx;
...
public void RefreshLbx()
{
    if (lbxQuotes.InvokeRequired)
    {
        lbxQuotes.Invoke(_refreshLbx);
    }
    else
    {
        lbxQuotes.DataSource = null;
        lbxQuotes.DataSource = _quotes;
    }
}


All this is required in order that the code gets executed on the GUI thread. Now, I'm simply updating a textbox with a sample (number). Nothing else.

I guess I could have stated my point better: yes, it is an asynchronous system and it is *possible* that a WM_PAINT would get processed while the textbox text is changing. I am aware of this. My complaint was that .NET designers used this sledgehammer solution to prevent any presentation rendering mishap (ie. my number is rendered while it is changing) by constraining all code to execute on the GUI thread. So this means that for every single interaction with any control - and there's a LOT of them, I'm supposed to write wrapper code around everything, and this wrapper code involves defining and creating delegates and rewriting all my code to include a conditional statement which tests for this invokability.

AND YOU'RE FINE WITH THIS.

Me, I think this is a horrible and terribly primitive solution and design. It would be better to leave me with using SendMessage() to inject my action into the GUI's Message-Loop.

And that's not to mention that the compiler gave no warnings, there was no runtime error, the code SILENTLY failed, and I had no idea that the timer implemented its actions with a (hidden) separate thread.

I am LESS than impressed.
GeneralRe: ListBox does not update when DataSource is changed Pin
Dave Kreskowiak30-May-13 16:19
mveDave Kreskowiak30-May-13 16:19 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp30-May-13 17:38
rbsbscrp30-May-13 17:38 
GeneralRe: ListBox does not update when DataSource is changed Pin
Dave Kreskowiak31-May-13 4:25
mveDave Kreskowiak31-May-13 4:25 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp31-May-13 5:41
rbsbscrp31-May-13 5:41 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen31-May-13 6:29
professionalEddy Vluggen31-May-13 6:29 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen31-May-13 6:27
professionalEddy Vluggen31-May-13 6:27 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp31-May-13 7:22
rbsbscrp31-May-13 7:22 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen31-May-13 7:30
professionalEddy Vluggen31-May-13 7:30 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp31-May-13 7:39
rbsbscrp31-May-13 7:39 
GeneralRe: ListBox does not update when DataSource is changed Pin
Eddy Vluggen31-May-13 8:32
professionalEddy Vluggen31-May-13 8:32 
GeneralRe: ListBox does not update when DataSource is changed Pin
TnTinMn6-Jun-13 9:08
TnTinMn6-Jun-13 9:08 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp6-Jun-13 12:38
rbsbscrp6-Jun-13 12:38 
GeneralRe: ListBox does not update when DataSource is changed Pin
TnTinMn6-Jun-13 13:26
TnTinMn6-Jun-13 13:26 
AnswerRe: ListBox does not update when DataSource is changed Pin
Chirag Baroliya R24-May-13 2:25
Chirag Baroliya R24-May-13 2:25 
GeneralRe: ListBox does not update when DataSource is changed Pin
rbsbscrp24-May-13 20:11
rbsbscrp24-May-13 20:11 
QuestionBinding a DataGridView column to a nullable property, using a ComboBox bound to a non-nullable property. Pin
Brady Kelly14-May-13 21:20
Brady Kelly14-May-13 21:20 
QuestionControl hide/show(should be post here, right?) Pin
kenmaMoon23-Apr-13 21:20
kenmaMoon23-Apr-13 21:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.