Click here to Skip to main content
15,905,967 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: The look and feel of the GUI in the application changes when executing from an MSI file created by Windows Install Pin
led mike23-Jul-08 5:42
led mike23-Jul-08 5:42 
Questionshow loading message Pin
SamRST17-Jul-08 4:04
SamRST17-Jul-08 4:04 
AnswerRe: show loading message Pin
Thomas Stockwell17-Jul-08 4:41
professionalThomas Stockwell17-Jul-08 4:41 
QuestionRepaint custom control when property changes in CollectionEditor Pin
willydemis16-Jul-08 11:39
willydemis16-Jul-08 11:39 
AnswerRe: Repaint custom control when property changes in CollectionEditor Pin
Thomas Stockwell17-Jul-08 2:48
professionalThomas Stockwell17-Jul-08 2:48 
GeneralRe: Repaint custom control when property changes in CollectionEditor Pin
willydemis17-Jul-08 4:01
willydemis17-Jul-08 4:01 
GeneralRe: Repaint custom control when property changes in CollectionEditor Pin
Thomas Stockwell17-Jul-08 4:39
professionalThomas Stockwell17-Jul-08 4:39 
GeneralRe: Repaint custom control when property changes in CollectionEditor Pin
willydemis17-Jul-08 10:29
willydemis17-Jul-08 10:29 
YES! You are my new hero! Laugh | :laugh:


My custom collection derives from System.Collections.CollectionBase which has a number of protected virtual methods that are fired when the collection is modified. Since the CollectionEditor is modifying the collection, I was able to hook in here.

I created a new delegate and event:
public delegate void OnRepaintControlHandler(object sender, EventArgs e);

public class AccentListViewItemCollection : CollectionBase
{
    public event OnRepaintControlHandler RepaintControl;
    ...



...Created an event handler:
protected virtual void OnRepaintControl(EventArgs e)
{
    if (RepaintControl != null)
    {
        RepaintControl(this, e);
    }
}



...And then overrode the events that I needed my control to repaint on:
protected override void OnValidate(object value)
{
    base.OnValidate(value);

    OnRepaintControl(new EventArgs());
}

protected override void OnSetComplete(int index, object oldValue, object newValue)
{
    base.OnSetComplete(index, oldValue, newValue);

    OnRepaintControl(new EventArgs());
}

protected override void OnRemoveComplete(int index, object value)
{
    base.OnRemoveComplete(index, value);

    OnRepaintControl(new EventArgs());
}

protected override void OnInsertComplete(int index, object value)
{
    base.OnInsertComplete(index, value);

    OnRepaintControl(new EventArgs());
}



Finally, I registered for the event in my control, and invalidated the control on getting the event:
public AccentListView()
{
    ...

    _Items = new AccentListViewItemCollection(this);
    _Items.RepaintControl += new OnRepaintControlHandler(_Items_RepaintControl);

    ...
}

private void _Items_RepaintControl(object sender, EventArgs e)
{
    this.Invalidate();
    this.Update();
}





Again, thanks for your help- pretty sure I would not have figured this out without it!
Questionc# for driver level Pin
knmsuman15-Jul-08 5:53
knmsuman15-Jul-08 5:53 
QuestionDataBindingComplete firing on form Visibility change Pin
bigbrownbeaver15-Jul-08 1:55
bigbrownbeaver15-Jul-08 1:55 
AnswerRe: DataBindingComplete firing on form Visibility change Pin
led mike15-Jul-08 5:05
led mike15-Jul-08 5:05 
GeneralRe: DataBindingComplete firing on form Visibility change Pin
bigbrownbeaver15-Jul-08 5:31
bigbrownbeaver15-Jul-08 5:31 
QuestionORA-00936:missing expression Pin
varun_mca_ju14-Jul-08 21:13
varun_mca_ju14-Jul-08 21:13 
QuestionCould not receive Meesages from Socket Pin
HemJoshi14-Jul-08 20:31
HemJoshi14-Jul-08 20:31 
QuestionResize problem with Listbox Pin
emailthiaga14-Jul-08 19:26
emailthiaga14-Jul-08 19:26 
AnswerRe: Resize problem with Listbox Pin
John Ad15-Jul-08 3:18
John Ad15-Jul-08 3:18 
GeneralRe: Resize problem with Listbox Pin
emailthiaga15-Jul-08 4:01
emailthiaga15-Jul-08 4:01 
AnswerRe: Resize problem with Listbox Pin
emailthiaga24-Jul-08 0:05
emailthiaga24-Jul-08 0:05 
AnswerRe: Resize problem with Listbox Pin
darkelv15-Jul-08 23:09
darkelv15-Jul-08 23:09 
AnswerCross Post Pin
Thomas Stockwell16-Jul-08 5:10
professionalThomas Stockwell16-Jul-08 5:10 
QuestionSkins.. Pin
Slick6914-Jul-08 0:06
Slick6914-Jul-08 0:06 
AnswerRe: Skins.. Pin
Thomas Stockwell15-Jul-08 8:46
professionalThomas Stockwell15-Jul-08 8:46 
QuestionA CheckBox with a LinkLabel Pin
Domenic Denicola13-Jul-08 12:27
Domenic Denicola13-Jul-08 12:27 
QuestionRead the URL of the Browser Pin
M_Menon13-Jul-08 5:00
M_Menon13-Jul-08 5:00 
Questionpassword change Pin
Sider8912-Jul-08 5:43
Sider8912-Jul-08 5:43 

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.