Click here to Skip to main content
15,916,692 members
Home / Discussions / C#
   

C#

 
QuestionDisable/enable CollectionEditor properties? Pin
kanchoette6-Jan-09 2:35
kanchoette6-Jan-09 2:35 
AnswerRe: Disable/enable CollectionEditor properties? Pin
Henry Minute6-Jan-09 2:58
Henry Minute6-Jan-09 2:58 
GeneralRe: Disable/enable CollectionEditor properties? Pin
kanchoette6-Jan-09 3:32
kanchoette6-Jan-09 3:32 
GeneralRe: Disable/enable CollectionEditor properties? Pin
Henry Minute6-Jan-09 4:25
Henry Minute6-Jan-09 4:25 
GeneralRe: Disable/enable CollectionEditor properties? Pin
kanchoette6-Jan-09 4:30
kanchoette6-Jan-09 4:30 
QuestionShowBalloonTip of notifyicon not working Pin
Tridip Bhattacharjee6-Jan-09 2:08
professionalTridip Bhattacharjee6-Jan-09 2:08 
AnswerRe: ShowBalloonTip of notifyicon not working Pin
Wendelius6-Jan-09 2:19
mentorWendelius6-Jan-09 2:19 
QuestionPanels - Changing their width and dealing with the Horizontal Scroll Bar Pin
Matthew Klein6-Jan-09 2:07
Matthew Klein6-Jan-09 2:07 
Hello All!

I have created a control that inherits from a Panel. My control has a method, UpdateControls() that repositions all of its child controls to where they need to be after they’ve been resized.

Sometimes the resizing causes the Vertical and Horizontal scroll bars to appear. I want the Vertical, but not the Horizontal, so at the end of the UpdateControls() method my control checks to see if the Vertical scroll is visible, and if it is, it increases its width so the Horizontal scroll bar isn’t needed.
protected void UpdateControls()
{
    this.SuspendLayout();

    int LastTop = this.AutoScrollPosition.Y;
    foreach (Control ic in _controls)
    {
        ic.Top = LastTop;
        LastTop = ic.Bottom + 5;
    }

    this.ResumeLayout(true);

    if (this.Width != this.NeededWidth)
    {
        this.Width = NeededWidth;
    }
}

public int NeededWidth
{
    get
    {
        if (this.VScroll)
            return _MaxWidth + 17;
        else
            return _MaxWidth;
    }
}

However, the form that contains my control isn’t updated properly. It seems to lag behind by one UpdateControls() call. It seems as though the resize of my control isn’t taking place until after all of the painting is done.

I’ve tried calling this.parent.Invalidate(true) and this.parent.Refresh() at the end of my UpdateControls() method, but neither force the new size to be used.

I found that by listening to the MyControl.SizeChanged event in MyForm and re-assigning the new width (after it had already been updated, thus triggering the SizeChanged event) will force the new size to be used, but MyControl gets drawn twice and it is noticeable on my form.
    _ItemsContainer = new MyControl();
    _ItemsContainer.SizeChanged += new EventHandler(_ItemsContainer_SizeChanged);
...
void _ItemsContainer_SizeChanged(object sender, EventArgs e)
{
    _ItemsContainer.Width = _ItemsContainer.NeededWidth;
}

How can I force the new size to be used so the Horizontal Scroll bars aren’t being drawn in my control?

Thank you!
AnswerRe: Panels - Changing their width and dealing with the Horizontal Scroll Bar Pin
EliottA6-Jan-09 2:14
EliottA6-Jan-09 2:14 
AnswerRe: Panels - Changing their width and dealing with the Horizontal Scroll Bar Pin
EliottA6-Jan-09 7:28
EliottA6-Jan-09 7:28 
AnswerRe: Panels - Changing their width and dealing with the Horizontal Scroll Bar Pin
#realJSOP6-Jan-09 8:31
professional#realJSOP6-Jan-09 8:31 
GeneralRe: Panels - Changing their width and dealing with the Horizontal Scroll Bar Pin
Matthew Klein6-Jan-09 10:28
Matthew Klein6-Jan-09 10:28 
Questionfilling and adding to byte array [modified] Pin
A4ad6-Jan-09 2:04
A4ad6-Jan-09 2:04 
AnswerRe: filling and adding to byte array Pin
Le centriste6-Jan-09 2:21
Le centriste6-Jan-09 2:21 
GeneralRe: filling and adding to byte array Pin
A4ad6-Jan-09 21:31
A4ad6-Jan-09 21:31 
GeneralRe: filling and adding to byte array Pin
Le centriste7-Jan-09 1:02
Le centriste7-Jan-09 1:02 
QuestionHow to change computer name with c# ? Pin
mshannaq6-Jan-09 1:44
mshannaq6-Jan-09 1:44 
AnswerRe: How to change computer name with c# ? Pin
Simon P Stevens6-Jan-09 1:55
Simon P Stevens6-Jan-09 1:55 
GeneralRe: How to change computer name with c# ? Pin
Luc Pattyn6-Jan-09 2:34
sitebuilderLuc Pattyn6-Jan-09 2:34 
QuestionFind .exe file using c# Pin
Abdul Rahman Hamidy6-Jan-09 1:12
Abdul Rahman Hamidy6-Jan-09 1:12 
AnswerRe: Find .exe file using c# Pin
Dave Kreskowiak6-Jan-09 7:42
mveDave Kreskowiak6-Jan-09 7:42 
GeneralRe: Find .exe file using c# Pin
Abdul Rahman Hamidy6-Jan-09 21:13
Abdul Rahman Hamidy6-Jan-09 21:13 
GeneralRe: Find .exe file using c# Pin
Dave Kreskowiak7-Jan-09 2:21
mveDave Kreskowiak7-Jan-09 2:21 
QuestionPerformance issue Pin
DJ2456-Jan-09 1:00
DJ2456-Jan-09 1:00 
AnswerRe: Performance issue Pin
Wendelius6-Jan-09 1:19
mentorWendelius6-Jan-09 1:19 

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.