473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Breaking from ListArray [C# WindowForms]

Hiya Everyone,

Hopefully someone can help.

I've created a ListArray and I am putting my data into custom buttons. The
background is this, The amount of data in the ListArray will very. The max
amount of buttons I will have is 15. If there is more than 15 items in the
ListArray then the 15th button will be a more button to cycle through and
display more items from the ListArray.

What I will need to do is break out of my function if there is "MORE" button
being displayed, and to check what the user button click/press is going to
be. If the user clicks on the "MORE" button then I need to continue with the
"foreach loop" of my ListArray, clear the controls and add a new amount of
buttons with more data from the ListArray, if not I will use the existing
button information for my application.

At this point I am unsure of the best syntax to be using for this. Any and
all help is appreciated. My Code is as follows:

private void Get_ArrayList()
{
ArrayList_Load_Data myArrayList_Load_Data = new ArrayList_Load_Data();
myArrayList = myArrayList_Load_Data.Test;

//*****If There Is Not Data Present
if(myArrayList.Count == 0)
{
MessageBox.Show("You have no Data");

while(btnCounter <= MaxButtonCount)
{
if(btnCounterTotal <= MaxColumnCount)
{
btnName = "";
btnText = "";
btnTabIndex = 0;
btnColor = System.Drawing.Color.Gray;

AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

ColumnPlacement = ColumnPlacement + 105;
btnCounter = btnCounter + 1;
btnCounterTotal = btnCounterTotal + 1;
}
else
{
btnName = "";
btnText = "";
btnTabIndex = 0;
btnColor = System.Drawing.Color.Gray;

RowPlacement = RowPlacement + 55;
ColumnPlacement = 0;

AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

ColumnPlacement = ColumnPlacement + 105;
btnCounterTotal = 2;
btnCounter = btnCounter + 1;
}
}
}
//*****If There Is Data Present. Display Data
else
{
foreach(DataItem myItem in myArrayList)
{
if(myItem.Index == btnCounterTotal)
{
btnName = "btn" + myItem.Name;
btnText = myItem.Name;
btnTabIndex = myItem.Index;
btnColor = System.Drawing.Color.FromName(myItem.Color);
Load_Default_Button();

myBlankCounter += 1;
}
else
{
while(myItem.Index != btnCounterTotal)
{
btnName = "";
btnText = "";
btnTabIndex = 0;
btnColor = System.Drawing.Color.Gray;
Load_Default_Button();

myBlankCounter += 1;
}
btnName = "btn" + myItem.Name;
btnText = myItem.Name;
btnTabIndex = myItem.Index;
btnColor = System.Drawing.Color.FromName(myItem.Color);
Load_Default_Button();

myBlankCounter += 1;
}
}
if(myArrayList.Count < MaxButtonCount)
{
while(myBlankCounter != MaxButtonCount)
{
btnName = "";
btnText = "";
btnTabIndex = 0;
btnColor = System.Drawing.Color.Gray;
Load_Default_Button();

myBlankCounter += 1;
}
}
}
private void Load_Default_Button()
{
if(btnCounter <= MaxButtonCount)
{
if(btnCounter <= MaxColumnCount)
{
if(btnCounterTotal == MaxButtonCount)
{
btnText1 = btnText;
btnName1 = btnName;
btnColor1 = btnColor;
btnTabIndex1 = btnTabIndex;

btnText = "MORE";
btnName = "";
btnColor = System.Drawing.Color.FromName("Gold");
btnTabIndex = 0;
AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

MaxButtonCount += MaxButtonCount;
}
else //If btnCounterTotal Does Not equal MaxButtonCount
{
AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);
ColumnPlacement = ColumnPlacement + 105;
btnCounter = btnCounter + 1;
btnCounterTotal = btnCounterTotal + 1;
}
}
else //If ColumnCounter is Greater Than MaxColumnCount
{ //Create a new Row
ColumnPlacement = 0;
RowPlacement = RowPlacement + 55;

AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

ColumnPlacement = ColumnPlacement + 105;
btnCounter = 2;
btnCounterTotal += 1;
}
}
else //If BtnCounter is Greater Than MaxButtonCount
{
}
}
private void AddControl(Control aControl, Point btnLocation, Size btnSize,
string btnName, String btnText, int btnTabIndex, System.Drawing.Color
btnColor)
{
aControl = new Test_Button.CustomButtons();
aControl.Name = btnName;
aControl.Text = btnText;
aControl.Font = new System.Drawing.Font("Tahoma", 9.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
aControl.TabIndex = btnTabIndex;
aControl.BackColor = btnColor;
aControl.Location = btnLocation;
aControl.Size = btnSize;
aControl.Click += new System.EventHandler(MYTEST);
this.Controls.Add(aControl);
}
private void MYTEST(object sender, System.EventArgs e)
{
Button mystring = (Button)sender;
if(mystring.Text == "MORE")
{
Controls.Clear();
btnText = btnText1;
btnName = btnName1;
btnColor = btnColor1;
btnTabIndex = btnTabIndex1;
btnCounter = 1;
ColumnPlacement = 0;
RowPlacement = 0;

AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

ColumnPlacement = 0;
RowPlacement = 0;
btnCounter += 1;
btnCounter += 1;
btnTabIndex += btnTabIndex1;
AddControl(new Button(), new Point(ColumnPlacement,RowPlacement), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

Load_Default_Button();
}
else
{
MessageBox.Show("TEXT: " + " " + mystring.Text + "\n" +
"NAME: " + " " + mystring.Name + " " + "\n" +
"BACKCOLOUR: " + " " + mystring .BackColor + "\n" +
"INDEX: " + " " + mystring.TabIndex.ToString());
}
}
Feb 15 '06 #1
0 3320

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

Similar topics

0
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme...
0
by: MarionEll | last post by:
XML Conference 2003 program now available…register with discounts now! IDEAlliance has just released the full program for XML 2003 scheduled December 7-12 at the Philadelphia Convention Center....
0
by: Amy | last post by:
I am looking for an rss feed that contains really important breaking news like "A large Tsunami just hit Asia" or "Terrorists attack the World Trade Center", but is empty if there really isn't...
0
by: melledge | last post by:
Deadline for XTECH 2005 Late-Breaking News and Vendor Presentations - 28 March The deadline for submission of Late-Breaking News and Vendor Presentations for IDEAlliance's XTCH 2005...
27
by: The Bicycling Guitarist | last post by:
Hi. I found the following when trying to learn if there is such a thing as a non-breaking hyphen. Apparently Unicode has a ‑ but that is not well-supported, especially in older browsers. Somebody...
22
by: stevenkobes | last post by:
If a word has a hyphen in it, IE will permit a line break at the hyphen, but Firefox/Mozilla won't. Apparently the Firefox behavior is standards-compliant, but it is not what I want. Is there a...
4
by: John Wood | last post by:
I saw that Microsoft have released a list of breaking changes in .Net here: http://msdn.microsoft.com/netframework/programming/breakingchanges/runtime/default.aspx While this is useful, it seems...
49
by: elmar | last post by:
Hi Clers, If I look at my ~200000 lines of C code programmed over the past 15 years, there is one annoying thing in this smart language, which somehow reduces the 'beauty' of the source code...
4
by: Rubin | last post by:
1) I want to show a breaking hyphen in Mozilla 1.5.0.4 How do I do that? "Unicode standard annex #14", <http://www.unicode.org/reports/tr14/>, defines 4 breaking hyphens. <quote> Breaking...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.