473,769 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Loa d_Data = new ArrayList_Load_ Data();
myArrayList = myArrayList_Loa d_Data.Test;

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

while(btnCounte r <= MaxButtonCount)
{
if(btnCounterTo tal <= MaxColumnCount)
{
btnName = "";
btnText = "";
btnTabIndex = 0;
btnColor = System.Drawing. Color.Gray;

AddControl(new Button(), new Point(ColumnPla cement,RowPlace ment), 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(ColumnPla cement,RowPlace ment), 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(DataIte m 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_Bu tton();

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

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

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

myBlankCounter += 1;
}
}
}
private void Load_Default_Bu tton()
{
if(btnCounter <= MaxButtonCount)
{
if(btnCounter <= MaxColumnCount)
{
if(btnCounterTo tal == 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(ColumnPla cement,RowPlace ment), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

MaxButtonCount += MaxButtonCount;
}
else //If btnCounterTotal Does Not equal MaxButtonCount
{
AddControl(new Button(), new Point(ColumnPla cement,RowPlace ment), 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(ColumnPla cement,RowPlace ment), 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(Cont rol aControl, Point btnLocation, Size btnSize,
string btnName, String btnText, int btnTabIndex, System.Drawing. Color
btnColor)
{
aControl = new Test_Button.Cus tomButtons();
aControl.Name = btnName;
aControl.Text = btnText;
aControl.Font = new System.Drawing. Font("Tahoma", 9.75F,
System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int,
((System.Byte)( 0)));
aControl.TabInd ex = btnTabIndex;
aControl.BackCo lor = btnColor;
aControl.Locati on = btnLocation;
aControl.Size = btnSize;
aControl.Click += new System.EventHan dler(MYTEST);
this.Controls.A dd(aControl);
}
private void MYTEST(object sender, System.EventArg s e)
{
Button mystring = (Button)sender;
if(mystring.Tex t == "MORE")
{
Controls.Clear( );
btnText = btnText1;
btnName = btnName1;
btnColor = btnColor1;
btnTabIndex = btnTabIndex1;
btnCounter = 1;
ColumnPlacement = 0;
RowPlacement = 0;

AddControl(new Button(), new Point(ColumnPla cement,RowPlace ment), new
Size(100,50), btnName, btnText, btnTabIndex, btnColor);

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

Load_Default_Bu tton();
}
else
{
MessageBox.Show ("TEXT: " + " " + mystring.Text + "\n" +
"NAME: " + " " + mystring.Name + " " + "\n" +
"BACKCOLOUR : " + " " + mystring .BackColor + "\n" +
"INDEX: " + " " + mystring.TabInd ex.ToString());
}
}
Feb 15 '06 #1
0 3337

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

Similar topics

0
2270
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme Markup Languages 2003 ************ --------------------------------------------------------- The regular (peer reviewed) part of the Extreme 2003 program has been scheduled. As usual, we have reserved a few slots on the Extreme program for...
0
1665
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. This year's event is chock full of sessions on Web Services, Publishing, Client Applications, Core Technologies, Knowledge Management, Government Applications, Vertical Industry Case Studies, and more. See the schedule at a glance for more...
0
1164
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 anything that important going on. All the rss feeds I've looked at contain quite a few entries as breaking news or top headlines, none of which seem really that urgent. Does anyone know of a good feed, or can point me to a more appropriate place...
0
1559
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 http://www.xtech-conference.org is Monday, 28 March. Please visit http://www.xtech-conference.org/2005/call.asp for submission information and guidelines.
27
31423
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 somewhere said: Alternately, you can use CSS to declare a class having: ..nowrap { white-space:nowrap } .... and then wrap the compound word in a <span class=nowrap></span> tag (or any other suitable inline tag). You can also try {...
22
8012
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 way to denote a hyphen in HTML, that the line can be broken after? I've read some stuff about soft hyphens and non-breaking hyphens, but those seem like the opposite of what I'm looking for. I want a normal hyphen, that always appears, and I...
4
1351
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 to be missing a change that has broken a lot of my applications, relating to the order in which members are returned by reflection. At least I can't find it. I reported the bug on ladybug:...
49
2807
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 ;-): char *cp; void *vp; void **vpp;
4
4558
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 hyphens establish explicit break opportunities immediately after each occurrence.
0
9579
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
9422
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
10038
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
9987
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,...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
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();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
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.