473,804 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Dynamic Controls and Displaying Page by Page on the form

Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.

I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly
--------------------------------------------------------------------------------------------
I need to create dynamically some controls on the forms, and display these
controls page by page on the form by using "Previous Page" and "Next Page"
buttons.

In detailed
--------------------------------------------------------------------------------------------
I will read some information from a file. The contents of this file include
Parameter information line by line. Each line is formatted. We may think
that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I
will create dynamically some controls for each line. Dynamically created
controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the
running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but
row data format will be same.

My form's size will be maximized. I want to create control groups as much
as on the form one under the other. Let's say the number of parameter is
1000, and It is possible to dynamically create 50 control groups on the form.
This means than it is required to create 20 different pages on the form.

These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next
Page" buttons?

I will receive some parameter values from TCP/IP socket periodically.
Therefore I have to change the received parameter values at the related
Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh

Jul 21 '05 #1
7 3567
Joe
This is VB.NET but I coded for 2 years in C++ and know this should make more
than enough sense to help you.

1. The first thing I always do is put a panel on my form.
You will stick all your controls on that panel, lets call it pnlMain.

Now create an object of your control. Lets say I want to put a checkbox on
there.
Dim oObjCheckBox As CheckBox = New CheckBox()
Give it all the attributes you want to give it
oObjCheckBox.ID = "chkIDOne"
oObjCheckBox.Te xt = "vbIsForGirlsan dCPPRule"
Now stick it on your panel
pnlMenus.Contro ls.Add(oObjChec kBox)
You can put this in your onload, but just check for postback, otherwise you
will lose youre changes on your controls. If you can do this (which should
be very easy) the rest will be easy as well. Put controls on your panels and
managed it from there

Hope it helps a bit, an if anything is not clear or if I misunderstood
you...just reply
regards

"Bil Muh" wrote:
Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.

I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly :
--------------------------------------------------------------------------------------------
I need to create dynamically some controls on the forms, and display these
controls page by page on the form by using "Previous Page" and "Next Page"
buttons.

In detailed :
--------------------------------------------------------------------------------------------
I will read some information from a file. The contents of this file include
Parameter information line by line. Each line is formatted. We may think
that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I
will create dynamically some controls for each line. Dynamically created
controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the
running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but
row data format will be same.

My form's size will be maximized. I want to create control groups as much
as on the form one under the other. Let's say the number of parameter is
1000, and It is possible to dynamically create 50 control groups on the form.
This means than it is required to create 20 different pages on the form.

These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next
Page" buttons?

I will receive some parameter values from TCP/IP socket periodically.
Therefore I have to change the received parameter values at the related
Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh

Jul 21 '05 #2
I thank You so much, Joe.

Your guidance will help me during my solution.

Please do allow me to ask my questions. Can you explain a bit more about
"postback" ? I could not understand what does it mean.

"Joe" wrote:
This is VB.NET but I coded for 2 years in C++ and know this should make more
than enough sense to help you.

1. The first thing I always do is put a panel on my form.
You will stick all your controls on that panel, lets call it pnlMain.

Now create an object of your control. Lets say I want to put a checkbox on
there.
Dim oObjCheckBox As CheckBox = New CheckBox()
Give it all the attributes you want to give it
oObjCheckBox.ID = "chkIDOne"
oObjCheckBox.Te xt = "vbIsForGirlsan dCPPRule"
Now stick it on your panel
pnlMenus.Contro ls.Add(oObjChec kBox)
You can put this in your onload, but just check for postback, otherwise you
will lose youre changes on your controls. If you can do this (which should
be very easy) the rest will be easy as well. Put controls on your panels and
managed it from there

Hope it helps a bit, an if anything is not clear or if I misunderstood
you...just reply
regards

"Bil Muh" wrote:
Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.

I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly :
--------------------------------------------------------------------------------------------
I need to create dynamically some controls on the forms, and display these
controls page by page on the form by using "Previous Page" and "Next Page"
buttons.

In detailed :
--------------------------------------------------------------------------------------------
I will read some information from a file. The contents of this file include
Parameter information line by line. Each line is formatted. We may think
that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I
will create dynamically some controls for each line. Dynamically created
controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the
running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but
row data format will be same.

My form's size will be maximized. I want to create control groups as much
as on the form one under the other. Let's say the number of parameter is
1000, and It is possible to dynamically create 50 control groups on the form.
This means than it is required to create 20 different pages on the form.

These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next
Page" buttons?

I will receive some parameter values from TCP/IP socket periodically.
Therefore I have to change the received parameter values at the related
Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh

Jul 21 '05 #3
Is there some specific reason why you don't want to use a DataGrid control ?

I'm saying this because dynamically creating a few thousand controls might
turn out to be a real performance killer for your application, no ?

If you construct a DataSet from your file ( or stream or whatever ) and
fiddle a bit with a DataGrid you could possibly do paging very easily.

Angel
O:]
"Bil Muh" <bi*********@ho tmail.com_REMOV E_THIS_PART> wrote in message
news:9B******** *************** ***********@mic rosoft.com...
Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.

I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly :
-------------------------------------------------------------------------- ------------------ I need to create dynamically some controls on the forms, and display these controls page by page on the form by using "Previous Page" and "Next Page"
buttons.

In detailed :
-------------------------------------------------------------------------- ------------------ I will read some information from a file. The contents of this file include Parameter information line by line. Each line is formatted. We may think
that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I
will create dynamically some controls for each line. Dynamically created
controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the
running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but
row data format will be same.

My form's size will be maximized. I want to create control groups as much as on the form one under the other. Let's say the number of parameter is
1000, and It is possible to dynamically create 50 control groups on the form. This means than it is required to create 20 different pages on the form.

These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next
Page" buttons?

I will receive some parameter values from TCP/IP socket periodically.
Therefore I have to change the received parameter values at the related
Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh

Jul 21 '05 #4
Actually, there is not any specific limitation in my application. Please let
me explaing my intention.

There is a one file that contains formated rows of data pertaining
parameters. The number of rows will not be fixed. Let's assume there are 1000
parameters in that file.
I am communicating with another computer via TCP/IP. Both computers have
the same file. My computer is client and other is server. Server generate
values for 1000 parameters and sends them to the client periodically.
At the client side, I want to display all recevied values for parameters
as quick as possible. I thought that having a Paging style display would be
user-friendly to observe the data. Due to having hundreds of parameters, I
want to display them page by page. But other solutions are acceptable.
My constraints are simple:
1) Be Fast,
2) Show All,
3) Enable dummies to understand immediately, how to observe other
parameters, that are not on that page...

For every parameters, I have to show the followings on the form:

Parameter_Name Parameter_Curre nt_Value Parameter_Unit

That's all...

Can you explain me how to use DataGrid to display values Almost-Real-Time
in the cells and How to show them similar to Page by Page type, please?

My Best Regards...



"Angelos Karantzalis" wrote:
Is there some specific reason why you don't want to use a DataGrid control ?

I'm saying this because dynamically creating a few thousand controls might
turn out to be a real performance killer for your application, no ?

If you construct a DataSet from your file ( or stream or whatever ) and
fiddle a bit with a DataGrid you could possibly do paging very easily.

Angel
O:]
"Bil Muh" <bi*********@ho tmail.com_REMOV E_THIS_PART> wrote in message
news:9B******** *************** ***********@mic rosoft.com...
Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.

I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly :
--------------------------------------------------------------------------

------------------
I need to create dynamically some controls on the forms, and display

these
controls page by page on the form by using "Previous Page" and "Next Page"
buttons.

In detailed :
--------------------------------------------------------------------------

------------------
I will read some information from a file. The contents of this file

include
Parameter information line by line. Each line is formatted. We may think
that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I
will create dynamically some controls for each line. Dynamically created
controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the
running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but
row data format will be same.

My form's size will be maximized. I want to create control groups as

much
as on the form one under the other. Let's say the number of parameter is
1000, and It is possible to dynamically create 50 control groups on the

form.
This means than it is required to create 20 different pages on the form.

These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next
Page" buttons?

I will receive some parameter values from TCP/IP socket periodically.
Therefore I have to change the received parameter values at the related
Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh


Jul 21 '05 #5
First, you can create a DataSet instance.

Add a DataTable, with Columns: Parameter_Name Parameter_Curre nt_Value
Parameter_Unit
... and then add a row for each line from your feed.

Conceptually, it's more or less the same as creating 3 Labels at the time,
the only real difference is that you can bind
the DataSet to a DataGrid control, and have the grid display the data
page-by-page.

I'm no expert on Windows Forms Controls like the DataGrid, but I do believe
strongly that with a little work you can get much more done with the
DataSet - DataGrid combination than by adding labels arbitrarily on your
form.

Sorry I couldn't be of more assistance,

Angel
O:]

For every parameters, I have to show the followings on the form:

Parameter_Name Parameter_Curre nt_Value Parameter_Unit

That's all...

Can you explain me how to use DataGrid to display values Almost-Real-Time
in the cells and How to show them similar to Page by Page type, please?

My Best Regards...



"Angelos Karantzalis" wrote:
Is there some specific reason why you don't want to use a DataGrid control ?
I'm saying this because dynamically creating a few thousand controls might turn out to be a real performance killer for your application, no ?

If you construct a DataSet from your file ( or stream or whatever ) and
fiddle a bit with a DataGrid you could possibly do paging very easily.

Angel
O:]
"Bil Muh" <bi*********@ho tmail.com_REMOV E_THIS_PART> wrote in message
news:9B******** *************** ***********@mic rosoft.com...
Esteemede Developers,

I would like to Thank All of You in advance for your sincere guidances.
I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.

Briefly :

--------------------------------------------------------------------------
------------------
I need to create dynamically some controls on the forms, and display

these
controls page by page on the form by using "Previous Page" and "Next Page" buttons.

In detailed :

--------------------------------------------------------------------------
------------------
I will read some information from a file. The contents of this file

include
Parameter information line by line. Each line is formatted. We may think that, this file is a Table with some columns of a database.

Format of each line is similar to following:
Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;

Firstly, I will read this file and determine how many rows exist. Then, I will create dynamically some controls for each line. Dynamically created controls are as below:
1. Param_Number : Label
2. Param_Name : Label
3. Default_Value : Label (contents of this field will change during the running of application)
4. Unit : Label

This group of controls will be created on the form dynamically.

The number of rows ( number of parameters) may change file to file, but row data format will be same.

My form's size will be maximized. I want to create control groups as

much
as on the form one under the other. Let's say the number of parameter is 1000, and It is possible to dynamically create 50 control groups on the
form.
This means than it is required to create 20 different pages on the

form.
These are my questions...!!

**** How can I create dynamically controls on the form? ,
**** How can I show them page by page on the form.? and
**** How can I go through on the pages with "Previous Page" and "Next Page" buttons?

I will receive some parameter values from TCP/IP socket periodically. Therefore I have to change the received parameter values at the related Labels in each page on the form.

I am requesting you to guide me ...

With this, I extend you and all yours with my bests.

Respectfully, yours

Bil Muh


Jul 21 '05 #6
Thank you very much Karantzalis for your kind interest and guidance.

I will try your suggestion as well.

Have a good day...
"Angelos Karantzalis" wrote:
First, you can create a DataSet instance.

Add a DataTable, with Columns: Parameter_Name Parameter_Curre nt_Value
Parameter_Unit
... and then add a row for each line from your feed.

Conceptually, it's more or less the same as creating 3 Labels at the time,
the only real difference is that you can bind
the DataSet to a DataGrid control, and have the grid display the data
page-by-page.

I'm no expert on Windows Forms Controls like the DataGrid, but I do believe
strongly that with a little work you can get much more done with the
DataSet - DataGrid combination than by adding labels arbitrarily on your
form.

Sorry I couldn't be of more assistance,

Angel
O:]

For every parameters, I have to show the followings on the form:

Parameter_Name Parameter_Curre nt_Value Parameter_Unit

That's all...

Can you explain me how to use DataGrid to display values Almost-Real-Time
in the cells and How to show them similar to Page by Page type, please?

My Best Regards...



"Angelos Karantzalis" wrote:
Is there some specific reason why you don't want to use a DataGrid control ?
I'm saying this because dynamically creating a few thousand controls might turn out to be a real performance killer for your application, no ?

If you construct a DataSet from your file ( or stream or whatever ) and
fiddle a bit with a DataGrid you could possibly do paging very easily.

Angel
O:]
"Bil Muh" <bi*********@ho tmail.com_REMOV E_THIS_PART> wrote in message
news:9B******** *************** ***********@mic rosoft.com...
> Esteemede Developers,
>
> I would like to Thank All of You in advance for your sincere guidances. >
> I am developing a software using Visual C++ .NET Standard Edition with
> Windows Form (.NET) template.
>
> Briefly :

--------------------------------------------------------------------------
------------------
> I need to create dynamically some controls on the forms, and display
these
> controls page by page on the form by using "Previous Page" and "Next Page" > buttons.
>
> In detailed :

--------------------------------------------------------------------------
------------------
> I will read some information from a file. The contents of this file
include
> Parameter information line by line. Each line is formatted. We may think > that, this file is a Table with some columns of a database.
>
> Format of each line is similar to following:
> Param_Number;Pa ram_Name;Defaul t_Value;Unit;In fo1;
>
> Firstly, I will read this file and determine how many rows exist. Then, I > will create dynamically some controls for each line. Dynamically created > controls are as below:
> 1. Param_Number : Label
> 2. Param_Name : Label
> 3. Default_Value : Label (contents of this field will change during the > running of application)
> 4. Unit : Label
>
> This group of controls will be created on the form dynamically.
>
> The number of rows ( number of parameters) may change file to file, but > row data format will be same.
>
> My form's size will be maximized. I want to create control groups as
much
> as on the form one under the other. Let's say the number of parameter is > 1000, and It is possible to dynamically create 50 control groups on the form.
> This means than it is required to create 20 different pages on the form. >
> These are my questions...!!
>
> **** How can I create dynamically controls on the form? ,
> **** How can I show them page by page on the form.? and
> **** How can I go through on the pages with "Previous Page" and "Next > Page" buttons?
>
> I will receive some parameter values from TCP/IP socket periodically. > Therefore I have to change the received parameter values at the related > Labels in each page on the form.
>
> I am requesting you to guide me ...
>
> With this, I extend you and all yours with my bests.
>
> Respectfully, yours
>
> Bil Muh
>


Jul 21 '05 #7
I coded an example for dynamic control creation. You may find the source
codes below:

1) This source codes are for Visual C++ .NET v.2003
2) Open a project by using "Windows Forms (.NET)."
3) Name the project as : "Panel_Denemele ri"
4) Paste the below source codes to "Form1.h" code view.
5) Compile, Debug and Build the program :)

Source Codes:
Kodlar :
// -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

/*************** *************** *************** *************

Coded by Alper AKCAYOZ

September 27th, 2004

bi*********@hot mail.com

*************** *************** *************** *************/

#pragma once

#include <windows.h>

#ifdef MessageBox
#undef MessageBox
#endif
namespace Panel_Denemeler i
{
using namespace System;
using namespace System::Threadi ng;
using namespace System::Compone ntModel;
using namespace System::Collect ions;
using namespace System::Windows ::Forms;
using namespace System::Data;
using namespace System::Drawing ;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change
the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public __gc class Form1 : public System::Windows ::Forms::Form
{
public:
Form1(void)
{
InitializeCompo nent();
}

////////////////////////////////////////////////////////////////////////////////////////////
//Panel
Panel __gc *panel1;
Thread* myThread;

////////////////////////////////////////////////////////////////////////////////////////////
static Int32 i32Panel_Number = 0;
static Int32 i32Label_Number = 0;
static Int32 i32SpaceBetween Controls = 5;
static Int32 i32LabelHeight = 20;
static Int32 i32LabelWidth = 130;
static Int32 i32Current_Pos_ X = 8;
static Int32 i32Current_Pos_ Y = 8;
private: System::Windows ::Forms::Label * lblControlCount ;
private: System::Windows ::Forms::Timer * timer1;
private: System::Windows ::Forms::Button * btnPreviousPage ;
private: System::Windows ::Forms::Button * btnNextPage;

static Int32 i32Current_Colu mn_Pos_X = 8 ;
////////////////////////////////////////////////////////////////////////////////////////////

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispos e(disposing);
}

private: System::Windows ::Forms::Button * bntCreatePanel;
private: System::Windows ::Forms::TextBo x * txtSiraSayisi;
private: System::Windows ::Forms::Button * btnKadarSiraYar at;
private: System::Windows ::Forms::Button * btnClearPanel;
private: System::Windows ::Forms::Label * lblSure;
private: System::Compone ntModel::IConta iner * components;
private:
/// <summary>
/// Required designer variable.
/// </summary>
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeCompo nent(void)
{
this->components = new System::Compone ntModel::Contai ner();
this->bntCreatePan el = new System::Windows ::Forms::Button ();
this->txtSiraSayis i = new System::Windows ::Forms::TextBo x();
this->btnKadarSiraYa rat = new System::Windows ::Forms::Button ();
this->btnClearPane l = new System::Windows ::Forms::Button ();
this->lblSure = new System::Windows ::Forms::Label( );
this->lblControlCoun t = new System::Windows ::Forms::Label( );
this->timer1 = new System::Windows ::Forms::Timer( this->components);
this->btnPreviousPag e = new System::Windows ::Forms::Button ();
this->btnNextPage = new System::Windows ::Forms::Button ();
this->SuspendLayout( );
//
// bntCreatePanel
//
this->bntCreatePan el->BackColor =
System::Drawing ::Color::FromAr gb((System::Byt e)255, (System::Byte)2 55,
(System::Byte)1 92);
this->bntCreatePan el->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 9, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->bntCreatePan el->ForeColor =
System::Drawing ::Color::FromAr gb((System::Byt e)0, (System::Byte)0 ,
(System::Byte)1 92);
this->bntCreatePan el->Location = System::Drawing ::Point(8, 8);
this->bntCreatePan el->Name = S"bntCreatePane l";
this->bntCreatePan el->Size = System::Drawing ::Size(104, 32);
this->bntCreatePan el->TabIndex = 0;
this->bntCreatePan el->Text = S"Create Panel";
this->bntCreatePan el->Click += new System::EventHa ndler(this,
bntCreatePanel_ Click);
//
// txtSiraSayisi
//
this->txtSiraSayis i->BorderStyle =
System::Windows ::Forms::Border Style::None;
this->txtSiraSayis i->CharacterCasin g =
System::Windows ::Forms::Charac terCasing::Uppe r;
this->txtSiraSayis i->Enabled = false;
this->txtSiraSayis i->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 20.25F, System::Drawing ::FontStyle::Re gular,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->txtSiraSayis i->ImeMode = System::Windows ::Forms::ImeMod e::NoControl;
this->txtSiraSayis i->Location = System::Drawing ::Point(128, 8);
this->txtSiraSayis i->MaxLength = 3;
this->txtSiraSayis i->Name = S"txtSiraSayisi ";
this->txtSiraSayis i->Size = System::Drawing ::Size(64, 31);
this->txtSiraSayis i->TabIndex = 1;
this->txtSiraSayis i->Text = S"";
this->txtSiraSayis i->TextAlign =
System::Windows ::Forms::Horizo ntalAlignment:: Center;
//
// btnKadarSiraYar at
//
this->btnKadarSiraYa rat->BackColor =
System::Drawing ::Color::FromAr gb((System::Byt e)255, (System::Byte)2 55,
(System::Byte)1 92);
this->btnKadarSiraYa rat->Enabled = false;
this->btnKadarSiraYa rat->Font = new System::Drawing ::Font(S"Micros oft
Sans Serif", 9, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->btnKadarSiraYa rat->ForeColor =
System::Drawing ::Color::FromAr gb((System::Byt e)0, (System::Byte)0 ,
(System::Byte)1 92);
this->btnKadarSiraYa rat->Location = System::Drawing ::Point(200, 8);
this->btnKadarSiraYa rat->Name = S"btnKadarSiraY arat";
this->btnKadarSiraYa rat->Size = System::Drawing ::Size(72, 32);
this->btnKadarSiraYa rat->TabIndex = 2;
this->btnKadarSiraYa rat->Text = S"pcs. Row";
this->btnKadarSiraYa rat->Click += new System::EventHa ndler(this,
bntKadarSiraYar at_Click);
//
// btnClearPanel
//
this->btnClearPane l->BackColor =
System::Drawing ::Color::FromAr gb((System::Byt e)255, (System::Byte)2 55,
(System::Byte)1 92);
this->btnClearPane l->Enabled = false;
this->btnClearPane l->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 9, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->btnClearPane l->ForeColor =
System::Drawing ::Color::FromAr gb((System::Byt e)0, (System::Byte)0 ,
(System::Byte)1 92);
this->btnClearPane l->Location = System::Drawing ::Point(280, 8);
this->btnClearPane l->Name = S"btnClearPanel ";
this->btnClearPane l->Size = System::Drawing ::Size(80, 32);
this->btnClearPane l->TabIndex = 3;
this->btnClearPane l->Text = S"Clear Panel";
this->btnClearPane l->Click += new System::EventHa ndler(this,
btnClearPanel_C lick);
//
// lblSure
//
this->lblSure->BackColor = System::Drawing ::Color::Silver ;
this->lblSure->Font = new System::Drawing ::Font(S"Micros oft Sans Serif",
12, System::Drawing ::FontStyle::Bo ld, System::Drawing ::GraphicsUnit: :Point,
(System::Byte)1 62);
this->lblSure->ForeColor = System::Drawing ::Color::Red;
this->lblSure->Location = System::Drawing ::Point(384, 8);
this->lblSure->Name = S"lblSure";
this->lblSure->Size = System::Drawing ::Size(624, 16);
this->lblSure->TabIndex = 4;
this->lblSure->TextAlign = System::Drawing ::ContentAlignm ent::MiddleCent er;
//
// lblControlCount
//
this->lblControlCoun t->BackColor = System::Drawing ::Color::Silver ;
this->lblControlCoun t->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 12, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->lblControlCoun t->ForeColor = System::Drawing ::Color::Red;
this->lblControlCoun t->Location = System::Drawing ::Point(384, 32);
this->lblControlCoun t->Name = S"lblControlCou nt";
this->lblControlCoun t->Size = System::Drawing ::Size(624, 16);
this->lblControlCoun t->TabIndex = 5;
this->lblControlCoun t->TextAlign =
System::Drawing ::ContentAlignm ent::MiddleCent er;
//
// timer1
//
this->timer1->Enabled = true;
this->timer1->Interval = 800;
this->timer1->Tick += new System::EventHa ndler(this, timer1_Tick);
//
// btnPreviousPage
//
this->btnPreviousPag e->BackColor =
System::Drawing ::Color::FromAr gb((System::Byt e)255, (System::Byte)2 55,
(System::Byte)1 92);
this->btnPreviousPag e->Enabled = false;
this->btnPreviousPag e->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 9, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->btnPreviousPag e->ForeColor =
System::Drawing ::Color::FromAr gb((System::Byt e)0, (System::Byte)0 ,
(System::Byte)1 92);
this->btnPreviousPag e->Location = System::Drawing ::Point(1024, 8);
this->btnPreviousPag e->Name = S"btnPreviousPa ge";
this->btnPreviousPag e->Size = System::Drawing ::Size(96, 40);
this->btnPreviousPag e->TabIndex = 6;
this->btnPreviousPag e->Text = S"<<< Previous";
//
// btnNextPage
//
this->btnNextPage->BackColor =
System::Drawing ::Color::FromAr gb((System::Byt e)255, (System::Byte)2 55,
(System::Byte)1 92);
this->btnNextPage->Enabled = false;
this->btnNextPage->Font = new System::Drawing ::Font(S"Micros oft Sans
Serif", 9, System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 62);
this->btnNextPage->ForeColor =
System::Drawing ::Color::FromAr gb((System::Byt e)0, (System::Byte)0 ,
(System::Byte)1 92);
this->btnNextPage->Location = System::Drawing ::Point(1128, 8);
this->btnNextPage->Name = S"btnNextPag e";
this->btnNextPage->Size = System::Drawing ::Size(80, 40);
this->btnNextPage->TabIndex = 7;
this->btnNextPage->Text = S"Next >>>";
//
// Form1
//
this->AutoScaleBaseS ize = System::Drawing ::Size(5, 13);
this->BackColor = System::Drawing ::Color::Black;
this->ClientSize = System::Drawing ::Size(1262, 725);
this->Controls->Add(this->btnNextPage) ;
this->Controls->Add(this->btnPreviousPag e);
this->Controls->Add(this->lblControlCoun t);
this->Controls->Add(this->lblSure);
this->Controls->Add(this->btnClearPanel) ;
this->Controls->Add(this->btnKadarSiraYa rat);
this->Controls->Add(this->txtSiraSayisi) ;
this->Controls->Add(this->bntCreatePanel );
this->FormBorderStyl e = System::Windows ::Forms::FormBo rderStyle::Fixe d3D;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = S"Form1";
this->StartPositio n =
System::Windows ::Forms::FormSt artPosition::Ce nterScreen;
this->Text = S"Form1 - Once Alt Alta Sonra Yan Yana Diz";
this->WindowState = System::Windows ::Forms::FormWi ndowState::Maxi mized;
this->Load += new System::EventHa ndler(this, Form1_Load);
this->DoubleClick += new System::EventHa ndler(this, Form1_DoubleCli ck);
this->ResumeLayout(f alse);

}
//THIS IS THE FUNCTION WHICH CREATES PANEL
private: System::Void bntCreatePanel_ Click(System::O bject * sender,
System::EventAr gs * e)
{
//Panel
panel1 = new Panel();
//+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
// Initialize the Panel control.
panel1->Location = System::Drawing ::Point(8,50);
panel1->Size = System::Drawing ::Size( (this->get_Width() - 30),
(this->get_Height() - 85));
// Set the Borderstyle for the Panel to three-dimensional.
panel1->BorderStyle = System::Windows ::Forms::Border Style::Fixed3D;
//Backcolor
panel1->set_BackColor( System::Drawing ::Color::Aqua);
//Name
panel1->Name = String::Concat( S"Panel_Name _",
(++i32Panel_Num ber).ToString() );
//TAG
panel1->Tag = i32Panel_Number .ToString();

//----------------------------------------------------------------------------------------

// Add the Panel control to the form.
this->Controls->Add(panel1);

txtSiraSayisi->Enabled = true;
btnKadarSiraYar at->Enabled = true;
bntCreatePanel->Enabled = false;
}

private: System::Void CreateRows_Func tion()
{
try
{
//Labels
Label __gc *lblA = new Label();
Label __gc *lblB = new Label();
Label __gc *lblC = new Label();
//+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
// Initialize the Label and TextBox controls.
lblA->Location = System::Drawing ::Point(i32Curr ent_Pos_X,
i32Current_Pos_ Y);
lblA->Text = String::Concat( S"Label_", (++i32Label_Num ber).ToString() );
lblA->Name = String::Concat( S"lblA_Name_ ",
(i32Label_Numbe r).ToString());
lblA->Size = System::Drawing ::Size(i32Label Width, i32LabelHeight) ;
lblA->TextAlign = System::Drawing ::ContentAlignm ent::MiddleLeft ;
lblA->ForeColor = System::Drawing ::Color::Yellow ;
lblA->BackColor = System::Drawing ::Color::Black;
lblA->Font = new System::Drawing ::Font(S"Micros oft Sans Serif", 9.75F,
System::Drawing ::FontStyle::Bo ld, System::Drawing ::GraphicsUnit: :Point,
(System::Byte)1 62);

//----------------------------------------------------------------------------------"------

//Update the current i32Current_Pos_ X and i32Current_Pos_ Y
i32Current_Pos_ X += (i32LabelWidth + i32SpaceBetween Controls) ;
//i32Current_Pos_ Y += ;
//+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
// Initialize the Label and TextBox controls.
lblB->Location = System::Drawing ::Point(i32Curr ent_Pos_X,
i32Current_Pos_ Y);
lblB->Text = String::Concat( S"lblB_Name_ ",
(i32Label_Numbe r).ToString());
lblB->Name = String::Concat( S"lblB_Name_ ",
(i32Label_Numbe r).ToString());
lblB->Size = System::Drawing ::Size(i32Label Width, i32LabelHeight) ;
lblB->TextAlign = System::Drawing ::ContentAlignm ent::MiddleLeft ;
lblB->ForeColor = System::Drawing ::Color::Yellow ;
lblB->BackColor = System::Drawing ::Color::Blue;
lblB->Font = new System::Drawing ::Font(S"Micros oft Sans Serif", 9.75F,
System::Drawing ::FontStyle::Bo ld, System::Drawing ::GraphicsUnit: :Point,
(System::Byte)1 62);

//----------------------------------------------------------------------------------------

//Update the current i32Current_Pos_ X and i32Current_Pos_ Y
i32Current_Pos_ X += (i32LabelWidth + i32SpaceBetween Controls) ;
//i32Current_Pos_ Y += ;
//+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
// Initialize the Label and TextBox controls.
lblC->Location = System::Drawing ::Point(i32Curr ent_Pos_X,
i32Current_Pos_ Y);
lblC->Text = String::Concat( S"lblC_Name_ ",
(i32Label_Numbe r).ToString());
lblC->Name = String::Concat( S"lblC_Name_ ",
(i32Label_Numbe r).ToString());
lblC->Size = System::Drawing ::Size(i32Label Width, i32LabelHeight) ;
lblC->TextAlign = System::Drawing ::ContentAlignm ent::MiddleLeft ;
lblC->ForeColor = System::Drawing ::Color::Yellow ;
lblC->BackColor = System::Drawing ::Color::Gray;
lblC->Font = new System::Drawing ::Font(S"Micros oft Sans Serif", 9.75F,
System::Drawing ::FontStyle::Bo ld, System::Drawing ::GraphicsUnit: :Point,
(System::Byte)1 62);

//----------------------------------------------------------------------------------------

//Update the current i32Current_Pos_ X and i32Current_Pos_ Y
i32Current_Pos_ X = i32Current_Colu mn_Pos_X ;
i32Current_Pos_ Y = i32Current_Pos_ Y + i32LabelHeight +
i32SpaceBetween Controls; ;

if ( (this->panel1->Height - i32Current_Pos_ Y) >=
(i32SpaceBetwee nControls + i32LabelHeight) )
{
}
else
{
//Alta sira konulamaz, yana konulabilir
i32Current_Colu mn_Pos_X = i32Current_Pos_ X + i32LabelWidth +
i32SpaceBetween Controls +
i32LabelWidth + i32SpaceBetween Controls + i32LabelWidth +
(5*i32SpaceBetw eenControls) ;
i32Current_Pos_ X = i32Current_Colu mn_Pos_X;
i32Current_Pos_ Y = 8;
}
// Add the Label controls to the Panel.
panel1->Controls->Add(lblA);
panel1->Controls->Add(lblB);
panel1->Controls->Add(lblC);

// Add the event handler that will handle the event when the
// mouse is hovered
lblA->Click += new System::EventHa ndler(this, labelXXX_Click) ;
lblB->Click += new System::EventHa ndler(this, labelXXX_Click) ;
lblC->MouseHover += new System::EventHa ndler(this, labelXXX_MouseH over);

//Buton Enable
btnClearPanel->Enabled = true;
}
catch(Exception * exp)
{
MessageBox::Sho w(Convert::ToSt ring(exp), S"Exception Thrown");
}
}

private: System::Void bntKadarSiraYar at_Click(System ::Object * sender,
System::EventAr gs * e)
{
if (txtSiraSayisi->Text->Trim()->Length >0 )
{
Int32 i32SiraSayisi = Convert::ToInt3 2(txtSiraSayisi->Text->Trim());

LARGE_INTEGER i64StartTime, i64StopTime , i64Frequency ;

//CPU frekansını al
QueryPerformanc eFrequency(&i64 Frequency);

if (QueryPerforman ceCounter(&i64S tartTime) != 0)
{

for( Int32 i32Index = 1; i32Index <= i32SiraSayisi; ++i32Index)
{
if ( ((this->panel1->Height - i32Current_Pos_ Y) >=
(i32SpaceBetwee nControls + i32LabelHeight) ) &&
( (this->panel1->Width - i32Current_Pos_ X) >= ( (5 *
i32SpaceBetween Controls) + (3*i32LabelWidt h))) )
{
CreateRows_Func tion();
//this->Refresh();
txtSiraSayisi->Text = Convert::ToStri ng(
Convert::ToInt3 2(txtSiraSayisi->Text->Trim()) - 1 );
}
else
{
break;
}
}

QueryPerformanc eCounter(&i64St opTime);
lblSure->Text = String::Concat( S"Row Creating Duration = ",
((long int)(double)((i 64StopTime.Quad Part - i64StartTime.Qu adPart) *
1000.0) / ((double)i64Fre quency.QuadPart )).ToString(),
S" mili seconds");
}

txtSiraSayisi->Focus();
}
}
private: System::Void btnClearPanel_C lick(System::Ob ject * sender,
System::EventAr gs * e)
{
try
{
LARGE_INTEGER i64StartTime, i64StopTime , i64Frequency ;

//CPU frekansını al
QueryPerformanc eFrequency(&i64 Frequency);

if (QueryPerforman ceCounter(&i64S tartTime) != 0)
{
panel1->Controls->Clear();

//Initialize the curretn location
i32Current_Pos_ X = 8;
i32Current_Pos_ Y = 8;
i32Current_Colu mn_Pos_X = 8 ;
i32Label_Number = 0;

//Buton Enable
btnClearPanel->Enabled = false;

QueryPerformanc eCounter(&i64St opTime);
lblSure->Text = String::Concat( S"Clearing Duration = ",
((long int)(double)((i 64StopTime.Quad Part - i64StartTime.Qu adPart) *
1000.0) / ((double)i64Fre quency.QuadPart )).ToString(),
S" mili seconds");
}
}
catch(...)
{

}
}

private: System::Void labelXXX_MouseH over(System::Ob ject * sender,
System::EventAr gs * e)
{
if (String::Compar e(sender->GetType()->ToString(),
S"System.Window s.Forms.Label") == 0)
{
// Create a button object to use in its place
Label* myLabel = dynamic_cast<La bel*>(sender);

// Display the text to the user
MessageBox::Sho w(String::Conca t(myLabel->Text, S" MouseHover"),
this->Text,
MessageBoxButto ns::OK, MessageBoxIcon: :Information);

}

}

private: System::Void labelXXX_Click( System::Object * sender,
System::EventAr gs * e)
{
if (String::Compar e(sender->GetType()->ToString(),
S"System.Window s.Forms.Label") == 0)
{
// Create a button object to use in its place
Label* myLabel = dynamic_cast<La bel*>(sender);

// Display the text to the user
MessageBox::Sho w(String::Conca t(myLabel->Text, S" is clicked!" ) ,
this->Text,
MessageBoxButto ns::OK, MessageBoxIcon: :Information);
}

}

private: System::Void Form1_Load(Syst em::Object * sender, System::EventAr gs
* e)
{
this->MinimumSize = System::Drawing ::Size(this->get_Width(),
this->get_Height() );
}

private: System::Void Form1_DoubleCli ck(System::Obje ct * sender,
System::EventAr gs * e)
{
this->WindowState = Maximized;
}

private: System::Void timer1_Tick(Sys tem::Object * sender,
System::EventAr gs * e)
{
if ( this->panel1 != NULL )
lblControlCount->Text = String::Concat( S"Number of Controls on Panel =
", this->panel1->Controls->Count.ToString ());
}

};
}

Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10810
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would then like that, when clicking the LinkButton, the user can be navigated to another page, carrying a variable. I would like to use server.transfer method instead of QueryString as I don't want the carried variable to be visible for the user.
5
419
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some controls on the forms, and display these
3
3323
by: sck10 | last post by:
Hello, When a person subits my web page, I do a simple check (validation) and if there are any errors, I create a variable (strValidateText) and set that value to a label on the form. What I am trying to do create an image button along with the html. I am getting the error: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.ImageButton'.
4
304
by: rn5a | last post by:
Assume that a ASPX page uses a user control named Address.ascx which has 2 TextBoxes. This ASCX page creates 2 properties named 'Address' & 'City' using the Get & Set statements: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)
15
5282
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
3
4377
balabaster
by: balabaster | last post by:
I've got a user control that builds a table of dynamic data based on a :LINQ class holding the data. The data is loaded using the LoadData(DataInstance) method. The table it builds contains a number of dynamic controls that themselves have postback/autopostback so the display of the control needs to be built at latest in the Page.Load event or the event handlers for the controls don't get wired up. Now if I have a page that uses this user...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.