473,221 Members | 2,215 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,221 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 3309

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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.