|
// Declare a new ButtonArray object.
ButtonArray btnArray;
ButtonArray tempArray;
btnArray = new ButtonArray(this);
tempArray = new ButtonArray(this);
private void CopyArray()
{
try
{
if(btnArray.Count > 0)
{
int iCounter;
for (int iButtonIndex = 0; iButtonIndex < btnArray.Count; iButtonIndex++)
{
if (btnArray[iButtonIndex] != null)
{
tempArray[iCounter++] = btnArray[iButtonIndex];
iCounter++;
}
}
}
else
{
MessageBox.Show("(COPY) ARRAY IS EMPTY");
}
}
catch(Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1);
}
}
----------------------------------------------------------------
CODE FOR BUTTONARRAY.CS BELOW
----------------------------------------------------------------
using System;
namespace ButtonArray
{
public class ButtonArray : System.Collections.CollectionBase
{
private readonly System.Windows.Forms.Form HostForm;
public System.Windows.Forms.Button AddNewButton()
{
// Create a new instance of the Button class.
System.Windows.Forms.Button aButton = new System.Windows.Forms.Button();
// Add the button to the collection's internal list.
this.List.Add(aButton);
// Add the button to the controls collection of the form
// referenced by the HostForm field.
HostForm.Controls.Add(aButton);
// Set intial properties for the button object.
aButton.Top = Count * 25;
aButton.Left = 100;
aButton.Tag = this.Count;
aButton.Text = "Button " + this.Count.ToString();
aButton.Click += new System.EventHandler(ClickHandler);
return aButton;
}
public ButtonArray(System.Windows.Forms.Form host)
{
HostForm = host;
this.AddNewButton();
}
public System.Windows.Forms.Button this [int Index]
{
get
{
return (System.Windows.Forms.Button) this.List[Index];
}
}
public void Remove(int iRemoveX)
{
// Check to be sure there is a button to remove.
if (this.Count > 0)
{
// Remove the last button added to the array from the host form
// controls collection. Note the use of the indexer in accessing
// the array.
// Remove the button indexed with the value of iRemoveX
HostForm.Controls.Remove(this[iRemoveX]);
this.List.RemoveAt(this.Count -1);
}
}
public void ClickHandler(Object sender, System.EventArgs e)
{
System.Windows.Forms.MessageBox.Show("You have clicked button " +
((System.Windows.Forms.Button) sender).Tag.ToString());
}
}
}
|
|
|
|
|
You have no set method (only get method) on the default indexer (this[]) property.
---
b { font-weight: normal; }
|
|
|
|
|
I see.. would you happen to have a suggestion on how to make this set method?
Thanks alot for the help so far
|
|
|
|
|
It's just the reverse of the get method.
set<br />
{<br />
this.List[Index] = value;<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
Thanks alot for the help!
|
|
|
|
|
In the Style definitions for a DataGrid I defined a DataGridBoolColumn to show Boxes for
the true/false-values in the DataView of the Grid.
To set/toggle Buttons I have to check out, if the Box in a [Row,Column] is set to Enable or Disable by the click-event / space-key (if cell selected).
I have included an eventhandler (DataChanged) for the DataTable which is bound to the Grid.
But only if the SelectedCell is changed, the event for DataChanged will be fired. So, how can I receive an event for the changed Value in the Box if the user do not change the Cell (only 1 Click in the Box to mark it) and won't leave the DataGrid (events validating/valdated therefore will not be fired) ?
Any Idea ?
- If Data is changed, you can see the shown pencil at the row-marker-column. May I fetch this event inside the Grid in any way? May this be a workaround?
|
|
|
|
|
I create a UserControl and add a TextBox into the control.I want to have a Text property,in order that set or get the TextBox.Text.But I know Control class had the same property,and then I key the code that in list
--------------------
public partial class UserControl1 : UserControl
{
string _t;
[Browsable(true)]
public override string Text
{
get
{
this.textBox1.Text = _t;
return _t;
}
set
{
_t = value;
this.textBox1.Text = _t;
}
...
}
-----------------------------
When I test the control,I modify the Text property in the Properties Designer of the VS.NET 2005,The Control.Text get a value.But I open the method InitializeComponent() ,I can not find the code that initialize control.Text.
So,When the test application running,The value that Text property of the TextBox in the control is lost.
Can you tell me why? How to deal with it? Thanks a lot!
|
|
|
|
|
I have the same problem as you say.
If you know how to solve, tell me please.
=== Game is power! ===
|
|
|
|
|
Hi
We have a database that is based on Linked List.
Searching Lineraly is quite time consuming and worst if it is the last item in the list.
Binary Search however is better, but requires SORTING the list.
Can anyone tell me how to implement the Hash Table.
Any link, example will be appreciated.
Thanks
KHALID
|
|
|
|
|
binary search of a linked list would not be that hard.
Hashtable takes two parameters key => val, and list only takes one val.
so you could have a table that has val => val, based on your val from linked list, BUT val (the key) must be unique in the hashtable instance.
hth
g00fy
|
|
|
|
|
hi there,
I'm pretty sure that there are a lot of great article on CP site
below is just one of them:
http://www.codeproject.com/dotnet/phonebook.asp
<< >>
|
|
|
|
|
You're lucky, you don't need to implement a hash table, the .NET FCL already has one (System.Collections.HashTable).
Or you can try SortedList[^] instead.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How can we create custom shaped Windows Forms in C#.NET
KHALID
|
|
|
|
|
|
I am ishtiaq. i am working at a project in which i am trying to use C for making windows base application.
i have two problems.
1. i am seeking such a funtion to whome i can use of inputting data from the user and then display it as out put back to the screen. the function outtext() or outtextxy() do not perform in put values from user.
2. and the other method for takig input is to use Window () function but we can use it with viewport() function but i am fail to use these both function window() and viewport() together.as microsoft word provide and there is not any example in any book that i have read yet.
please send me any code that will be use for that one.thanks a lot
my email address is imtiaztkd@yahoo.com bye
ishtiaq ahmad from pakistan
E/668, shah rukn-e-alam colony , Multan, pakistan
|
|
|
|
|
Sorry if it's a bit silly, I'm just learning. I have code that looks like
textBoxHomePhone.Text = node.InnerText;
node = contactNode.SelectSingleNode("WorkPhone");
Now only the first line (till 'the extension') appears in the task list. I don't want to merge the lines since it would run off the screen. Adding HACK: to the succeeding lines creates multiple tasks. Is it possible to do something wherein the whole comment would appear as a single task?
Help is appreciated!
Cheers,
Vikram.
http://www.geocities.com/vpunathambekar
Google talk: binarybandit After all is said and done, much is said and little is done.
|
|
|
|
|
It's possible to create a multiline comment by using the /* comment */ notation.
The bigger issue is that the task list is a grid, and it appears that you only get one line per task (everything up to the fist newline character), so even creating something like
while it is technically a single comment, will not appear all on the single line provided by the task list.
You are better off just using that first line (everything following the 'HACK:' tag as a descriptive title for the rest of your comment. That way its appearance in the task list will give the developer(s) an idea what the task is about.
Since navigating to tasks is as simple as double-clicking, it's not worth getting too excited about the shortcomings of this feature, IMO.
Hope this helps,
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thanks for the tip, Turbochimp - I'll do as you suggest.
Cheers,
Vikram.
http://www.geocities.com/vpunathambekar
Google talk: binarybandit After all is said and done, much is said and little is done.
|
|
|
|
|
Hi guys.
i new in c#, now there a pro..
i currently writin a pro to check so value for some number.
problem is before i do that i check for any alphahent in e number input.. cos for my case only number.
But the problem is if i key in "MMM" the thing get stuck in a for loop for three time.
is there a command like C.. EXIT where they exit the program immendiate
|
|
|
|
|
If it's a Windows app, simply call Application.Exit() .
If it's a console app, you can use return; or return 0; depending on your declaration of Main().
HTH.
Cheers,
Vikram.
http://www.geocities.com/vpunathambekar
Google talk: binarybandit After all is said and done, much is said and little is done.
|
|
|
|
|
if by using return it goes back to where the loop is..
i wanna break out of that loop and exit the program.. or is there a way to clear all the input in the program
|
|
|
|
|
You can explicitly terminate a console app by calling Environment.Exit() . Look at this:
using System;
class Class1
{
public static int Main(string[] args)
{
Console.WriteLine("Hello");
Environment.Exit(0);
Console.WriteLine("Bye");
return 0;
}
}
However, I do not know how 'safe' it is to call that method. HTH.
Cheers,
Vikram.
http://www.geocities.com/vpunathambekar
Google talk: binarybandit After all is said and done, much is said and little is done.
|
|
|
|
|
not sure of your explanation
if you are trying to break a loop, i *really* dont like he break keyword except for switch (but that is just me) i like o gracefully exit a loop like this
<br />
bool found = false;<br />
<br />
while(!found )<br />
{ <br />
if(condition)<br />
{<br />
found = true;<br />
}<br />
}<br />
<code><br />
<br />
hth<br />
g00fy<br />
<br />
-- modified at 5:13 Friday 16th September, 2005
|
|
|
|
|
in C# webform i get the value in javascript ,i want send value to next webform through the javascript
m mohamad rafi
|
|
|
|
|
Put the value in a hidden field.
---
b { font-weight: normal; }
|
|
|
|