Click here to Skip to main content
15,029,260 members
Home / Discussions / Windows Forms
   

Windows Forms

 
AnswerRe: Logging for Windows Form application PinPopular
NotPolitcallyCorrect17-Jul-13 4:09
MemberNotPolitcallyCorrect17-Jul-13 4:09 
QuestionWinforms - automated retrieve static image Pin
fincity11-Jul-13 7:51
Memberfincity11-Jul-13 7:51 
AnswerRe: Winforms - automated retrieve static image Pin
Richard MacCutchan11-Jul-13 21:16
mveRichard MacCutchan11-Jul-13 21:16 
AnswerRe: Winforms - automated retrieve static image Pin
Eddy Vluggen9-Oct-13 7:30
professionalEddy Vluggen9-Oct-13 7:30 
QuestionError during tableAdapterManager.UpdateAll unable to resolve Pin
Member 838780830-Jun-13 8:02
MemberMember 838780830-Jun-13 8:02 
AnswerRe: Error during tableAdapterManager.UpdateAll unable to resolve Pin
Eddy Vluggen4-Jul-13 5:05
professionalEddy Vluggen4-Jul-13 5:05 
QuestionListBox does not update when DataSource is changed Pin
rbsbscrp17-May-13 5:36
Memberrbsbscrp17-May-13 5:36 
AnswerRe: ListBox does not update when DataSource is changed Pin
rbsbscrp17-May-13 6:59
Memberrbsbscrp17-May-13 6:59 
Wow but this is weird. Okay, I found the solution because I tried the recommendation given below:

lbxQuotes.DataSource = null;
lbxQuotes.DataSource = _quotes;
lbxQuotes.SelectionMode = SelectionMode.None;
lbxQuotes.SelectionMode = SelectionMode.One;


That is, I added the SelectionMode two lines... and this caused (only once) a "from different thread" exception. Weird, I'm NOT running a method - I'm changing data... hmmm... I wonder if the DataSource is instead a Property (which secretly runs a method). D'oh!

Okay, so the solution was to create a delegate in the main form, for the RefreshLbx method, and have the RefreshLbx method recursively call this, as below:

public void RefreshLbx()
{
    if (lbxQuotes.InvokeRequired)
    {
        lbxQuotes.Invoke(_refreshLbx);
    }
    else
    {
        lbxQuotes.DataSource = null;
        lbxQuotes.DataSource = _quotes;
    }
}


with the _refreshLbx delegate defined in the form's class as:

private delegate void RefreshLbxDg8();
private RefreshLbxDg8 _refreshLbx;


Then just init the delegate in the form constructor (after the InitializeComponent() call):

_refreshLbx = RefreshLbx;


Now I am able to update the listbox contents from a timer handler.
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
Memberrbsbscrp24-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
Memberrbsbscrp30-May-13 14:16 
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
Memberrbsbscrp30-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
Memberrbsbscrp31-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
Memberrbsbscrp31-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
Memberrbsbscrp31-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
MemberTnTinMn6-Jun-13 9:08 

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.