|
Hi guys,
does anyone know how to underline just one word within a lable?
|
|
|
|
|
You'd need to create your own control to do that.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Subclass System.Windows.Forms.Label control and override OnPaint method. Use the graphics object and work with DrawString()[^] method.
|
|
|
|
|
|
i don't suppose you know of any good tutorials on this?
|
|
|
|
|
Until now i used a "List<student>" to going over a lot of students (not from DB) and i want to keep to best 10 student (maybe later i will want to save 10,000 and more) .
I used to list<student> and every time im insert a student and then sort the list. After the sorting im checking if there is more then 10 student and then take out the lower grade in the list.
The problem is that every iteration im sorting the list that is allready sorted because there is one new stduent that been insert to the list.
Is there ant other way to do it?
(i tryed to use SortList and you can see the problem , the key is the grade and it's possible that 2 student will have the same grade).
What is the best option?
If i have SortList and i want to save 10 object with the best result how can i do it?
For example if i have a student class and the comparison function between 2 stduent is by grade how can i save a list with the best 10 stduent?
(if 2 stduent have the same grade i have a problem with the key).
class Student : IComparable
{
public int id;
public int grade;
public string studentName;
public int CompareTo(object obj)
{
Student std = (Student)obj;
return std.grade - this.grade;
}
}
public SortedList GetTheBest10Student()
{
SortedList sortList = new SortedList();
for (int i = 0; i < StudentNumber; i++)
{
Student std = GetThisStudent(i);
sortList.Add(i, std);
if (sortList.Count > 10)
sortList.RemoveAt(10);
}
return sortList;
}
Thanks and regards,
Shai, Bonzai.
modified on Wednesday, August 19, 2009 5:12 AM
|
|
|
|
|
bonzaiholding wrote: The problem is that every iteration im sorting the list that is allready sorted because there is one new stduent that been insert to the list.
You need insertion sort and don't sort the whole list for each insertion. When adding an item, compare with all the items in the list and find a suitable position for that new item. Complexity of this will be O(n).
bonzaiholding wrote: (i tryed to use SortList and you can see the problem , the key is the grade and it's possible that 2 student will have the same grade).
What is the best option?
I don't see any problem here.
bonzaiholding wrote: If i have SortList and i want to save 10 object with the best result how can i do it?
Take the last or first 10 elements from the list depending on your sort order.
|
|
|
|
|
Thanks.
I tryed some other methods but in the end i just use this function :
private void InsertThisStudent(Student std, List<Student> List)
{
for (int i = 0; i < List.Count; i++)
{
if (std.CompareTo(List[i]) < 0)
{
List.Insert(i, std);
return;
}
}
List.Add(std);
}
thanks
|
|
|
|
|
Hi,
I have developed an application in C# i have done the GUI interaction.
But i want to invoke the API's through CMD.Please gaide me how to do C# application through command line.
With Regards
Mahesh
|
|
|
|
|
maheesh wrote: But i want to invoke the API's through CMD
Invoke APIs? Do you want to start the application through command line? If yes, go to the application directory and type your executable name. If you need to pass additional parameters to the program, pass it after the executable name. Something like
yourexename.exe arg1 arg2 arg3
You can read these in the program's main method.
|
|
|
|
|
I need to pass the parametes like
1.Input file name and path selection
2.Output Folder path selection
Not to invoke the form application,i have genarated class library file of my application.
I want to invoke the dll through cmd
Please help me
With Regards
Mahesh
|
|
|
|
|
Do you mean that you want to call methods in your (GUI) application via Command line arguments?
In that case, just handle the arguments in your application's Main method before the Application.Run(...) call is made.
|
|
|
|
|
Not GUI application.
The main functionality of my application i made as class library.
I want to provide inputs to class Library through CMD.
GUI part i have done.
with Regards
Mahesh
|
|
|
|
|
Okay, then create a Console Application and add the DLL assembly as a reference and make calls to the methods in your DLL by passing on the command line arguments from the Main method.
|
|
|
|
|
Ive created a custom control which fires event, and it works fine when I drag the control onto a form, and In that form I can create the event handler.
But now im dynamically loading the control into the form during runtime(Assembly.LoadFrom etc.). So obviously below that creating code when I try say userCtrl.myEvent += new EventHandler(this.myHandler); it wont work.
I understand why it doesnt work, I just have no clue what to do.
Thanks
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Why are you using Assembly.LoadFrom ? You can add control dynamically like this:
YourUserControlClass userCtrl = new YourUserControlClass();
userCtrl.myEvent += new EventHandler(this.myHandler);
this.Controls.Add(userCtrl);
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
By dynamically I mean totally dynamically. Like they browse and select a dll. So its not included in the solution before runtime.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
In that case, EventInfo class will help you. See this[^] link.
Or this[^] one.
Hope it helps.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
i need to validate the Textboxes that are created at runtime. The text should not be blank and it should allow only numbers.
|
|
|
|
|
Use a MaskedTextBox[^] instead.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
maybe validate against a regex? ^\d+$
you could put it in the TextChange event handler method
eks.
private void textBox1_TextChanged(object sender, EventArgs e)
{
Regex r=new Regex(@"^\d+$");
Match m=r.Match(textBox1.text);
if(!m.Success) MessageBox.Show("Wrong input format");
}
or you could check the content of the textbox when it is submited, in the same fasion, using Regex and Match classes.
one idea is to make a class that inherits from the TextBox class, add a string attribute that can hold the regex expression, and use that class instead of the TextBox and store the regex in that variable, then you could just loop through all the controls when the user subits the data, an check it against the regex stored in that control, like this:
public class ExtTextBox:TextBox
{
public string ValidationRegEx;
}
....
ExtTextBox newETB=new ExtTextBox();
...
...
newETB.ValidationRegex=@"^\d+$";
...
this.Controls.add(newETB);
foreach(Control c in this.Controls)
{
if(c is ExtTextBox)
{
ExtTextBox tmpC=(ExtTextBox)c;
Regex r=new Regex(tmpC.ValidationRegex);
Match m=r.Match(tmpc.Text);
if(!m.Success)
{
}
}
}
modified on Wednesday, August 19, 2009 5:00 AM
|
|
|
|
|
Dear All:
Am trying to learn how to secure web application does any body knows resources that are really helpfull?? I read an article her in CodeProject that talks about basePages and how they inherit each other to authenticate what is good is that i already work with this methodology but i did not know that this way was a really good one, but as you all know we developers can't get enough so any one could help?????
Thanks
|
|
|
|
|
khalil.kamel wrote: Am trying to learn how to secure web application
IMO, this is subjective. Here[^] is a MSDN technet article which talks about some general techniques. You may be interested in this[^] wiki as well.
|
|
|
|
|
Ok thanks but am searching for this kind of article please check it it is really niceCodeProject Article
these kind of articles that would make a developer better that others and this is what am searching for
|
|
|
|
|
hi all,
i have a datagridview, i want to check cell value in CellEndEdit event. if the cell is empty, don't allow to leave it.
how can i do it?
|
|
|
|