|
|
|
Hi,
In my project, i have to access the controls of a running application for ex, a Accessing all controls of a running windows
application developed in .net.I have to get all those controls of the running application and change its caption.
ex(buttonName,LabelName etc).I tried to implemented that ,but only caption of label alone gets changed and Button captions
and other control captions are not changed.I am working in C# windows applications.Please provide me the code in C#.Thanks in
advance.
regards,
Sherin
|
|
|
|
|
Since, on windows, the controls will be created and drawn via the windows API, I suggest you enumerate all the child windows via EnumChildWindows[^] and call SetWindowText[^] on each of the controls you like to change.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I want to freeze win form for, say, 5 min after a wrong username and password is entered for three times.
Its not the will, its the wish which drives fortune!
|
|
|
|
|
Thread.Sleep(300000)
|
|
|
|
|
Or simply Form.Enabled = false and enabling the form again after a Timer with tick 300000.
Freezing the thread is a bit harsh
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This[^] should get you started.
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Bah! We all know this is better!
DateTime end = (DateTime.Now).AddMinutes(5d);
while (DateTime.Now < end) ;
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
C'mon, we're advocating re-use here. And the classic name too...
public static void Delay(Double timeToTwiddle){
DateTime end = (DateTime.Now).AddMinutes(timeToTwiddle);
while (DateTime.Now < end) ;
}
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Bah that doesn't work if you want to use minutes, seconds, and ect...
if you want code reuse the following is the best:
public static void Delay(double years, double months, double days, double hours, double minutes, double seconds, double milliseconds){
DateTime end = DateTime.Now;
end.AddDays(days);
end.AddHours(hours);
end.AddMilliseconds(milliseconds);
end.AddMinutes(minutes);
end.AddMonths(months);
end.AddSeconds(seconds);
end.AddYears(years);
while (DateTime.Now < end) ;
}
remember to overload if you don't want to delay that long!
public static void Delay (double months, double days, double hours, double minutes, double seconds, double milliseconds){
Delay(0, months, days, hours, minutes, seconds, milliseconds);
}
public static void Delay(double days, double hours, double minutes, double seconds, double milliseconds){
Delay(0, days, hours, minutes, seconds, milliseconds);
}
public static void Delay(double hours, double minutes, double seconds, double milliseconds){
Delay(0, hours, minutes, seconds, milliseconds);
}
public static void Delay(double minutes, double seconds, double milliseconds){
Delay(0, minutes, seconds, milliseconds);
}
public static void Delay(double seconds, double milliseconds){
Delay(0, seconds, milliseconds);
}
public static void Delay(double milliseconds){
Delay(0, milliseconds);
}
If anyone uses this code, that's ok with me. Just so long as you post here and tell me the product/software name you're adding it to
so we can avoid it like the plague, and then you can state your name followed by and i"m an idiot!"
modified on Thursday, June 19, 2008 3:37 PM
|
|
|
|
|
Fantastic point, but what if you want 6 years and 12 milliseconds? I don't think that code can do that without wasting time typing in all those zeros into the function signature. Aren't we supposed to minimize typing?
public static void DelaySixYearsZeroMonthsZeroDaysZeroHoursZeroMinutesZeroSecondsAndSixMilliseconds(){
DateTime end = DateTime.Now;
end.AddMilliseconds(12);
end.AddYears(6);
while (DateTime.Now < end) ;
}
There. That can be reused indefinitely to wait 6 years and 12 milliseconds.
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
|
You even made the correct typo by writing AndSixMilliseconds and then adding 12ms!
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Why not just exit out of it? Freezing a form for 5 minutes is ugly and will guarantee that the user either kills it with task manager, reboots or calls for help.
At the very least, you should display some sort of message to let them know it's locked.
|
|
|
|
|
Probably what actually will happen is, he will get a lot of bug report saying that the application hangs.
|
|
|
|
|
Multiple combo-boxes are being populated using a single Access database.........but everytime I select any of the combo-box, the values in all other combo boxes also changes accordingly........since I want to generate a report using multiple selections of combo-box I want all combo-boxes to have different values of my choice.......how can i do that.........pls help me out.......!!!
- Thanks
|
|
|
|
|
You asked the same question[^] two days ago and did not respond to my answer
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks for the reply.........but I'm not getting any clue as how can I use multiple datasources when I'm using only one Access database............"empDB" is the access table and "EmpdID" is the field and likewise other fields in the same way....
pls see the used code below and guide ........
***********************************************************************************
comboID.DataSource = myDS.Tables["empDB"];
comboID.DisplayMember = "EmpID";
comboName.DataSource = myDS.Tables["empDB"];
comboName.DisplayMember = "EmpName";
comboProfession.DataSource = myDS.Tables["empDB"];
comboProfession.DisplayMember = "EmpProfession";
comboCountry.DataSource = myDS.Tables["empDB"];
comboCountry.DisplayMember = "EmpCountry";
***********************************************************************************
|
|
|
|
|
Verghese wrote: comboID.DataSource = myDS.Tables["empDB"];
comboID.DisplayMember = "EmpID";
comboName.DataSource = myDS.Tables["empDB"];
comboName.DisplayMember = "EmpName";
comboProfession.DataSource = myDS.Tables["empDB"];
comboProfession.DisplayMember = "EmpProfession";
comboCountry.DataSource = myDS.Tables["empDB"];
comboCountry.DisplayMember = "EmpCountry";
You are using the same data source (see bold).
To have each combobox be selected seperately, have 4 different DataSet to be assigned to the 4 combo boxes.
|
|
|
|
|
Anyway, Thanx for the reply...........but I got it the other way round........see code below......
*******************************************************************************************
OleDbConnection con = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand("select emp_name,emp_desig from emp", con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0]);
comboBox2.Items.Add(dr[1]);
//add as many comboboxes you want to
}
dr.Close();
*******************************************************************************************
|
|
|
|
|
Hello everyone,
I am doing input parameter checking for a string type, and string value except empty is valid. My function is provided to outer client to call. Sometimes I find to check null is not enough, I also need to check String.Empty.
My question is, what are the differences between null and String.Empty? I have made some web search for the answers but not very useful information.
thanks in advance,
George
|
|
|
|
|
Null indicates that the string has not been initialised. Empty means that there is a zero-length string in there.
|
|
|
|
|
Thanks Pete,
1.
For String.Empty, as you said, it represents a string initialized, but length is zero. Initialized means constructed (constructor called)?
2.
All variables initialized to String.Empty are pointing to the same memory address or not?
e.g.
String a = String.Empty;
String b = String.Empty;
a and b pointing to the same memory area?
regards,
George
|
|
|
|
|
George_George wrote: For String.Empty, as you said, it represents a string initialized, but length is zero. Initialized means constructed (constructor called)?
Yes.
string empty1 = "";
string empty2 = string.Empty;
string empty3 = new string(''); etc.
George_George wrote: All variables initialized to String.Empty are pointing to the same memory address or not?
Yes. String is a reference type. Therefore when you assign a string to another variable you are just assigning the reference.
|
|
|
|