|
1. In the code below I refine an array and add two properties to it. I can add elements to this array but can not read them back.
public class C_myList : System.Collections.ArrayList
{
public C_myList()
{
}
public void Add(string sString, int iNumber)
{
m_sString = sString;
m_iNumber = iNumber;
base.Add(this);
}
//refine the arraylist by adding two properties
public int m_iNumber;
public string m_sString;
}
2. Now I would like to add some items to this array and read them back. I can add them but what is the syntax for reading them back?
private void button1_Click(object sender, System.EventArgs e)
{
C_myList aList = new C_myList();
for(int i=0; i < 20; i++)
{
aList.Add(i.ToString(), i * 2 );
}
/*for(int x =0; x < 5; x++)
{
int ivalue = xList[x];
int ivalue2= xList[x].m_iMajorTabOrder;
}*/
}
thanks
|
|
|
|
|
are you sure your code is correct?
what is the intention of base.Add(this) ?
eperales
|
|
|
|
|
make life easy for yourself. store the information in a struct, then use ArrayList to store an array of structs.
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|
There is VSS in Visual Studio 6.0. But I can't find it in Visual Studio .Net
Anyone know why?
Thanks in advance.
|
|
|
|
|
Its there. Check your file_Sourcecontrol menu. and check your Tools_options_sourcecontrol menu.
Installer is probably in 3rd or 4th CD.
You will be needing atleast VSS 6.0c to work with .NET.
Regards.
NetPointer
|
|
|
|
|
You can alternatively use Borland's Starteam Personal Edition. It has VS.NET integration.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
i need to have all the names of the textboxes on my form put into an array. is there a way to dynamically set up an array of all the textboxes on my form?
Thanks,
.gonad.
|
|
|
|
|
You can get controls in your form by this.Controls property in your form,then check the type of each one and if it is TextBox put it in an array.
Mazy
No sig. available now.
|
|
|
|
|
Let me give you a few clues. I am new at this so bear with me.
1. Read through all controls on the form, like this
..
private ArrayList m_VisibleList = new ArrayList(); //poor name, it is all controls not just visible ones
...
public void BuildListOfAllControlsOnForm()
{//build a list of all controls on the form
m_VisibleList.Clear();
m_VisibleList.Add(this);
ArrayList aPendingControlListTemp = new ArrayList();//used to avoid
aPendingControlListTemp.Add(this);
System.Windows.Forms.Control CtrlParent = null;
System.Windows.Forms.Control CtrlChild = null;
for(int i=0; i < aPendingControlListTemp.Count; i++)
{//progress thru for loop for the form and any tab pages or frame
CtrlParent = (System.Windows.Forms.Control)aPendingControlListTemp[i];
for(int iIter = 0; iIter < CtrlParent.Controls.Count; iIter++)
{
CtrlChild = CtrlParent.Controls[iIter];
Debug.WriteLine("Parent hash " + CtrlParent.GetHashCode() + " Child hash " + CtrlChild.GetHashCode());
m_VisibleList.Add(CtrlChild);
if(CtrlChild.Controls.Count > 0)
{//tab page or frame control
aPendingControlListTemp.Add(CtrlChild);
}
}
}
aPendingControlListTemp.Clear();
int iCount = 0;
foreach(System.Windows.Forms.Control Ctrl in m_VisibleList)
{
Debug.WriteLine(++iCount + " " + Ctrl.Text );
}
}//BuildListOfAllControlsOnForm
2nd. Loop through your list and ask which are Textboxes, that code would be something like this
...
System.Windows.Forms.Control Traverse; where Traverse would point to an element in VisibleList.
...
if(Traverse.GetType() == typeof(CheckBox) ||
Traverse.GetType().IsSubclassOf(typeof(CheckBox)))
{//do special case handling for check box
System.Windows.Forms.CheckBox pCheck = (System.Windows.Forms.CheckBox)Traverse;
if(pCheck.Checked== false)
{
Traverse.Focus();
break;
}
}
Let me know if this is too much and I will try to refine it for you.
|
|
|
|
|
static void GetTextBoxes(Control parent, ArrayList list)
{
foreach (Control ctrl in parent.Controls)
{
if (ctrl as TextBox != null)
list.Add(ctrl.Name);
GetTextBoxes(ctrl, list);
}
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
This should work:
ArrayList names = new ArrayList();
foreach(Control ctrl in myForm.Controls)
{
if(ctrl is TextBox) names.Add(ctrl.Name);
}
I don't need no steenkin' LSD. If I want to see technicolour smears, I just give my daughter pizza for dinner.
-Jamie Hale
|
|
|
|
|
All of the solutions given to you will work, if you just want textbox controls on the "FORM".
But if your form contains tab-controls or frame-controls and you would like to know what/if these containers also contain textbox controls, then I think you need the solution I gave you.
Lastly, if you do not care about textbox controls nested inside tab pages that are not active you could use GetNextControl().
Here is an example.
public void SetFocusOnFirstEmptyControl()
{
int iCount=0;
System.Windows.Forms.Control Traverse = this;
//System.Reflection
while(Traverse != null)
{
Debug.WriteLine(++iCount + " " + Traverse.Text );
//myChild.GetType().BaseType.Equals(typeof(myFatherClass))
if(Traverse.GetType() == typeof(CheckBox) ||
Traverse.GetType().IsSubclassOf(typeof(CheckBox)))
{//do special case handling for check box
System.Windows.Forms.CheckBox pCheck = (System.Windows.Forms.CheckBox)Traverse;
if(pCheck.Checked== false)
{
Traverse.Focus();
break;
}
}
if(Traverse.Text.Length == 0)
{//test controls like textbox and dropdown
Traverse.Focus();
break;
}
Traverse = GetNextControl(Traverse, true);
}//while
}//SetFocusOnFirstEmptyControl
You have a lot of good people helping you. An answer is assured.
|
|
|
|
|
you're right, i really appreciate your help on this and i have learned a LOT of stuff from everyone helping and i thank you.
I got exactly what i needed and didn't even think about what you said regarding the textboxes on panels and tabs. i just thought it would show everything, but i was wrong.
Thanks very much for everyone's help.
.gonad.
|
|
|
|
|
Im using two listboxes and the second one fills upon SelectedIndexChanged from the first. when I set the datasource to either their respective SelectedIndexChanged event gets fired for each item that is contained in the listbox.
I was able to add all the items I need to the listbox via forloop and listbox.Items.Add, using a collection class for ValueMember and DisplayMember
but its pretty ugly compared to one line of code setting the datasource property.
is this supposed to happen when using the datasource property ?
----------this is what works:
public class Customer<br />
{<br />
public string CustomerDescription;<br />
public int CustomerID;<br />
public override string ToString()<br />
{<br />
return CustomerDescription;<br />
}<br />
}<br />
\\<br />
<br />
foreach(DataRow row in ds.Tables[0].Rows)<br />
{<br />
Customer newCustomer = new Customer();<br />
newCustomer.CustomerDescription = row["CustomerDesc"].ToString();<br />
newCustomer.CustomerID = System.Convert.ToInt32( row["CustomerID"] );<br />
lbCustomers.Items.Add( newCustomer );<br />
}
-- Kevin
|
|
|
|
|
I have a small problem here, but I am new to C# or .NET for that matter. I have a table row which I will put below, that needs to appear different when being viewed by Netscape. In IE it needs to display this:
Then in Netscape it needs to display this:
The only difference is, I took out the "Bookmark this page link" because it doesn't work in Netscape. Can anyone help me, I really need to get this working. Again this is a user control in C#. Thanks.
::C. VanDyke::
|
|
|
|
|
Hi...
I have written a proxy based web ad blocker in C#. The idea behind this is to route all HTTP traffic thru my program, so that banner ads can be blocked.
Browser's proxy settings are set to localhost and the port to the listening port, eg. localhost:8888
I am using a Tcplistener to listen to requests, and Httpwebrequest & webresponse to handle http traffic. everything seems fine. however, lately i notice that although the proxy is running, settings are correct, and browsers are configured to forward the requests to my proxy server, the requests are NOT sent to my proxy. I know this becoz i have a listview that will list all incoming traffic to the proxy, Browser windows just give me the "page cannot be displayed" message and the like.
At times after nemurous retries, the thing finnally worked and i can surf to almost anywhere with any browser. But when i shut down my proxy and load it again, i will get the same problem.
this proxy app is my degree project and it's gonna due in 14 days. i dunno wut's wrong. can some1 pls help me out?
|
|
|
|
|
How can I disable individual items in a CheckedListBox? I have a bit field in a db saying wether the item should be enabled/disabled and I want to make that item grayed out and not selectable.
Thanks.
Robert L. Edwards
|
|
|
|
|
you can access the individual checkboxes during the OnItemDataBound event.
|
|
|
|
|
I am looking for Cardinal Splines C# Implementation.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
|
No! Let me say: I am looking for how cardinal spline formulas are implemented, I am looking for its source code.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
|
Hi there !
I want to create a configurtion file, something like ProjectName.exe.config file, which will include XML elemnts that don't have "key" and "value".
For example:
<server id='BR.1.ET' address='127.0.0.1' dbg='true' maxClients='4' description='Server details'>
I want to read without going through all the nodes and attributes. Is there something similar to this method:
String dsn = ConfigurationSettings.AppSettings["pubs"];
?
Bye
|
|
|
|
|
nahumtakum wrote:
I want to read without going through all the nodes and attributes. Is there something similar to this method:
Well, you are going to have to write your own implementation of IConfigurationSectionHandler . Take a look at my article : An extension for a Configuration Settings class in .NET[^]
-Nick Parker
|
|
|
|
|
Hi Nick !
Can you please supply me the Test.exe.config file you are working with in your article ?
Thanks.
|
|
|
|