Click here to Skip to main content
15,889,732 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: OpenFileDialog exceptions Pin
MannyTheMammoth5-Oct-11 19:53
MannyTheMammoth5-Oct-11 19:53 
QuestionLinking two pages using Visual STudio Pin
Jomon T Jose26-Sep-11 16:53
Jomon T Jose26-Sep-11 16:53 
AnswerRe: Linking two pages using Visual STudio Pin
RobCroll10-Oct-11 12:11
RobCroll10-Oct-11 12:11 
GeneralRe: Linking two pages using Visual STudio Pin
rajeevcapgeminiindia17-Nov-11 19:50
rajeevcapgeminiindia17-Nov-11 19:50 
Questiondock a windows form into ppt application window Pin
shama_12325-Sep-11 21:18
shama_12325-Sep-11 21:18 
AnswerRe: dock a windows form into ppt application window Pin
Dave Kreskowiak26-Sep-11 3:40
mveDave Kreskowiak26-Sep-11 3:40 
QuestionVisual Studio insists my form has changed Pin
Wjousts22-Sep-11 4:05
Wjousts22-Sep-11 4:05 
AnswerRe: Visual Studio insists my form has changed Pin
RobCroll24-Sep-11 12:01
RobCroll24-Sep-11 12:01 
GeneralRe: Visual Studio insists my form has changed Pin
Wjousts27-Sep-11 11:41
Wjousts27-Sep-11 11:41 
AnswerRe: Visual Studio insists my form has changed Pin
Alan N24-Sep-11 20:59
Alan N24-Sep-11 20:59 
AnswerRe: Visual Studio insists my form has changed Pin
Eddy Vluggen26-Sep-11 8:33
professionalEddy Vluggen26-Sep-11 8:33 
GeneralRe: Visual Studio insists my form has changed Pin
Wjousts27-Sep-11 11:43
Wjousts27-Sep-11 11:43 
AnswerRe: Visual Studio insists my form has changed Pin
Wjousts27-Sep-11 11:41
Wjousts27-Sep-11 11:41 
QuestionWindows::Forms::ListView Repaint-Bug Pin
Allgaeuer9-Sep-11 1:14
Allgaeuer9-Sep-11 1:14 
Hello,

i have a question regarding the System::Windows::Forms::ListView. There's a bug witch i can't get rid of.
The intention was to create a ListView item whose last column adjusts to the available space of the surrounding panel. Please check the following code:

Form1.h:

C++
#pragma once

#include "MDIChild.h"

namespace ListView_Test {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();

            MDIChild ^ child = gcnew MDIChild();
            child->MdiParent=this;
            child->Show();
		}

	protected:
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		System::ComponentModel::Container ^components;

        void InitializeComponent(void)
		{
            this->SuspendLayout();
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(1060, 484);
            this->IsMdiContainer = true;
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->ResumeLayout(false);

        }
	};
}


MDIChild.h:

C++
#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace ListView_Test {

	public ref class MDIChild : public System::Windows::Forms::Form
	{
	public:
		MDIChild(void)
		{
			InitializeComponent();
		}

	protected:
		~MDIChild()
		{
			if (components)
			{
				delete components;
			}
		}

    private: System::Windows::Forms::ListView^  listView1;
    private: System::Windows::Forms::ColumnHeader^  columnHeader1;
    private: System::Windows::Forms::ColumnHeader^  columnHeader2;
    private: System::Windows::Forms::ColumnHeader^  columnHeader3;
    private: System::Windows::Forms::ColumnHeader^  columnHeader4;
    private: System::Windows::Forms::ColumnHeader^  columnHeader5;
    private: System::Windows::Forms::ColumnHeader^  columnHeader6;
    private: System::Windows::Forms::ColumnHeader^  columnHeader7;
    private: System::Windows::Forms::ColumnHeader^  columnHeader8;

		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

		void InitializeComponent(void)
		{
            System::Windows::Forms::ListViewItem^  listViewItem1 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"1", 
                L"a", L"b", L"c", L"d", L"e", L"f", L"g", L"h"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem2 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"2", 
                L"b", L"c", L"d", L"e", L"f", L"g", L"h", L"i"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem3 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"3", 
                L"c", L"d", L"e", L"f", L"g", L"h", L"i", L"j"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem4 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"4", 
                L"d", L"e", L"f", L"g", L"h", L"i", L"j", L"k"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem5 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"5", 
                L"e", L"f", L"g", L"h", L"i", L"j", L"k", L"l"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem6 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"6", 
                L"f", L"g", L"h", L"i", L"j", L"k", L"l", L"m"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem7 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"7", 
                L"g", L"h", L"i", L"j", L"k", L"l", L"m", L"n"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem8 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"8", 
                L"h", L"i", L"j", L"k", L"l", L"m", L"n", L"o"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem9 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"9", 
                L"i", L"j", L"k", L"l", L"m", L"n", L"o", L"p"}, -1));
            System::Windows::Forms::ListViewItem^  listViewItem10 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^  >(9) {L"0", 
                L"j", L"k", L"l", L"m", L"n", L"o", L"p", L"q"}, -1));
            this->listView1 = (gcnew System::Windows::Forms::ListView());
            this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader5 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader6 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader7 = (gcnew System::Windows::Forms::ColumnHeader());
            this->columnHeader8 = (gcnew System::Windows::Forms::ColumnHeader());
            this->SuspendLayout();
            // 
            // listView1
            // 
            this->listView1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
                | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(8) {this->columnHeader1, this->columnHeader2, 
                this->columnHeader3, this->columnHeader4, this->columnHeader5, this->columnHeader6, this->columnHeader7, this->columnHeader8});
            this->listView1->FullRowSelect = true;
            this->listView1->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Nonclickable;
            this->listView1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ListViewItem^  >(10) {listViewItem1, listViewItem2, 
                listViewItem3, listViewItem4, listViewItem5, listViewItem6, listViewItem7, listViewItem8, listViewItem9, listViewItem10});
            this->listView1->Location = System::Drawing::Point(6, 15);
            this->listView1->Name = L"listView1";
            this->listView1->Size = System::Drawing::Size(710, 110);
            this->listView1->TabIndex = 2;
            this->listView1->UseCompatibleStateImageBehavior = false;
            this->listView1->View = System::Windows::Forms::View::Details;
            this->listView1->SizeChanged += gcnew System::EventHandler(this, &MDIChild::ResizeListView);
            // 
            // columnHeader1
            // 
            this->columnHeader1->Text = L"Main";
            // 
            // columnHeader2
            // 
            this->columnHeader2->Text = L"Sub1";
            // 
            // columnHeader3
            // 
            this->columnHeader3->Text = L"Sub2";
            // 
            // columnHeader4
            // 
            this->columnHeader4->Text = L"Sub3";
            // 
            // columnHeader5
            // 
            this->columnHeader5->Text = L"Sub4";
            // 
            // columnHeader6
            // 
            this->columnHeader6->Text = L"Sub5";
            // 
            // columnHeader7
            // 
            this->columnHeader7->Text = L"Sub6";
            // 
            // columnHeader8
            // 
            this->columnHeader8->Text = L"Sub7";
            this->columnHeader8->Width = 55;
            // 
            // MDIChild
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(721, 139);
            this->Controls->Add(this->listView1);
            this->Name = L"MDIChild";
            this->Text = L"MDIChild";
            this->ResumeLayout(false);

        }
#pragma endregion

        void ResizeListView(System::Object ^ sender, System::EventArgs ^ e)
        {
            try
            {
                ListView ^ list = listView1;

                int nSize = 3;
                int nLastIndex = 7;
                int nLastColumnSize;

                nSize += list->Columns[0]->Width;
                nSize += list->Columns[1]->Width;
                nSize += list->Columns[2]->Width;
                nSize += list->Columns[3]->Width;
                nSize += list->Columns[4]->Width;
                nSize += list->Columns[5]->Width;
                nSize += list->Columns[6]->Width;

                nLastColumnSize = 200;

                nSize = list->ClientRectangle.Width - nSize - 19;

                if (nSize > nLastColumnSize)
                {
                    nLastColumnSize = nSize;
                }

                list->Columns[nLastIndex]->Width = nLastColumnSize;
            }
            catch(...)
            {
                ;
            }
        }
	};
}


As you can see an outer panel(Form1) serves as an MDI container for the interior(MDIChild) which contains the list view.

But if a list view item is displayed, witch content encompasses so many lines that the vertical scroll bar appears, a interessting repaint error arises when maximizing. But only if the ListView was scrolled down bevor the maximize. Presumably it happens because i set the size of the last column header, while the list view is redrawn.

Reproduction:
1.Execute the code posted above.
2.Move the vertical scroll bar of the "MDIChild" window to the bottom.
3.(optional) maximize the Form1.
4.The MDIChild maximize window.

Symptoms:
First, no line is displayed. If we try to mark some lines with a marking-rectangle, it is noticeable that they will not appear until you move the mouse over them. But at the wrong place. They seem to be moved downwards exactly of the height of the non-maximized panel. Even after you press the minimize button, the rows remain initially disappeared, until you move the scroll bar to the bottom.

Additionally a horizontal scroll bar is present, which is, compared to the size of the list view, much to wide. When you move it to the right side, the scroll bar is reduced to the proper width.

Can anyone help me with this problem? -In appendix there is a screenshot showing the problem.


Sincerely,

Michael
GeneralRe: Windows::Forms::ListView Repaint-Bug Pin
MicroVirus12-Sep-11 2:56
MicroVirus12-Sep-11 2:56 
QuestionWaitCursor, again Pin
lukeer8-Sep-11 22:00
lukeer8-Sep-11 22:00 
AnswerRe: WaitCursor, again Pin
GenJerDan9-Sep-11 4:02
GenJerDan9-Sep-11 4:02 
GeneralRe: WaitCursor, again Pin
lukeer11-Sep-11 22:40
lukeer11-Sep-11 22:40 
GeneralRe: WaitCursor, again Pin
GenJerDan12-Sep-11 3:10
GenJerDan12-Sep-11 3:10 
AnswerRe: WaitCursor, again Pin
MicroVirus9-Sep-11 13:30
MicroVirus9-Sep-11 13:30 
GeneralRe: WaitCursor, again Pin
BillWoodruff9-Sep-11 14:55
professionalBillWoodruff9-Sep-11 14:55 
GeneralRe: WaitCursor, again Pin
lukeer11-Sep-11 23:58
lukeer11-Sep-11 23:58 
GeneralRe: WaitCursor, again Pin
BillWoodruff12-Sep-11 2:04
professionalBillWoodruff12-Sep-11 2:04 
AnswerRe: WaitCursor, again Pin
MicroVirus12-Sep-11 2:51
MicroVirus12-Sep-11 2:51 
AnswerRe: WaitCursor, again Pin
MikeTheFid12-Jan-12 9:12
MikeTheFid12-Jan-12 9:12 

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.