|
Hello gurus,
I have a simple question for C# masters concerning controls.
I have a series of label with a formated name.
In a loop, I want to recover a pointer on the control (a label) by giving its name as a string.
for example:
<br />
Label lbl = null;<br />
string lblName = "";<br />
<br />
for (int i=0; i<5; i++)<br />
{<br />
lblName = "lblL" + i.ToString();
<br />
lbl = ???;
<br />
<br />
lbl.Text = i.ToString();<br />
}<br />
<br />
How to make the control pointing to the right one given its name?
I hope you understood my question in my poor english.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Hi Fred,
Would the following solve your problem:
lbl = new Label();
lbl = (Label)FindControl("lblName");
Ryan
|
|
|
|
|
Yes, that's it, in a recursive way and for WinForms.
There is no spoon.
modified on Thursday, March 12, 2009 10:41 AM
|
|
|
|
|
Sorry, my mistake. How about something like this:
Control myControl = new Control();
foreach (Control c in this.Controls)
{
if (c.Name == "lblName")
{
myControl = c;
}
}
|
|
|
|
|
Is this[^] what you looking?
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Something like that but for WinForms...
There is no spoon.
|
|
|
|
|
The is no FindContol method in WinForm. You can implenet your own
for this to work the control names need to be unique.
public static Control FindControl(string controlName)
{
if (!controlName.Empty)
return this.Controls.Find(controlName, true)[0];
return null;
}
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Ok, got it
Thanks.
There is no spoon.
|
|
|
|
|
you dont need to loop the controls, you can simple access it like an array and specify the control name, i.e.
Label lbl = (Label)Form1.Controls[lblName];
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
now i want to do the security code for atm program on consol application
like if the user of the ATM entered the Ac\No and the PIN CODE No 3 times wrong gives messege (the card has been confiscated please go to customer serviec).
i make the all program for ATM complately but this point i can not reach it
thanks
yours
btata
|
|
|
|
|
are you saying you have already done it, and you can not get it anymore?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
does your ATM gives out dispenses money?
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
If I undestood well:
just create a variable, and increment it whenever the user fails to insert acc and pass. Once it reachs the times you set as limit (3) dont allow the user to log anymore.
Hope this helps.
|
|
|
|
|
hmmmm... counter? if you are having problems with this then you really need to look at all your codes.
|
|
|
|
|
Read the PIG. You build an 0100 message, to identify the card (block 3) and pin (14). An 0110 response from the card system will let you know if the card should be retained or not; the ATM protocol just relies on the server telling it to retain card or not. I can't remember the blocks, but you have to check both the return code and the message.
Hope this helps.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
hello.. i have a webseit in asp.net web developer. when i compile the file its running on my machine on 127.0.0.1 ie the localhost. but it cannot be accessed from the other ip address ie by refering to the machine ip rather than the localhost.
what is the procedure to access the as.net website from other systems...
|
|
|
|
|
well you need to host it. using IIS or something
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
i tried IIS v 5.0 and could access the pages.. but the asp tags are not executed and i get the tags as output rather than their result. . . .
|
|
|
|
|
when you run your application from visual studio, it does not run within IIS. see what the address looks like.
The simples solution is publish your application to your local IIS, then users can get to it by
http://your_machine_name/your_application_name from within your network.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
How could we Pop a Context Menu anywhere on Screen?? (given the coordinates)
If there's a method please do mention...otherwise my only option is to create a borderless form and make it appear at those coordinates? (but i don't want to use that...)
modified 20-Oct-19 21:02pm.
|
|
|
|
|
|
Use Show() of CMS
eg
contextMenuStrip1.Show();
contextMenuStrip1.Show(x, y);
contextMenuStrip1.Show(textbox, x, y);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Doh!, Thanks guys!
modified 20-Oct-19 21:02pm.
|
|
|
|
|
I have a picturebox on the screen. I also have a panel with some information on the panel.
I can move/drag the panel over the screen. But I want that the panel only moves between the borders
of the picturebox. I don't now how to do this?
Can anyone help me to solve this problem?
|
|
|
|
|
As the panel 'moves' check in the event handler that it is in the correct area.
Have a go, if it doesn't work then post a code snippet.
Code helps. Nearly as well as gin.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|