|
Recommendations:
1) Don't use "class" for a class name... really don't. use "Course" or something appropriate. Never use keywords as class names or in parts of class names.
2) If it has to do with the class directly, then put it into that class. i.e. I'd put public static GetStudent() into the Student class.
3) Remember the "has-a" and "is-a" relationship. Curriculum has Courses. Courses have Students. I don't think you have a problem that requires inheritance here, so don't worry about the "is-a" relationship.
4) When you have problems getting started, it helps greatly to do the UML, even if it's sloppy who cares as long as you get a better understanding of the problem. Use a pencil and paper, don't worry about visio or other fancy tools. Pencils are twice as fast as visio - easy.
5) I presume that this is a student assignment? I'll give you a hint here, what you have is a nested problem, if you solve the Course/Students relationship, then you solved the Curriculum/Courses relationship.
Curriculum
-Courses
+Add(Course)
+Remove(Course)
+this[index]
Course
-Students
+Add(Student)
+Remove(Student)
+this[index]
+GetCourse(fromDB)
Student
-StudentInfo() //Info that I'm not going to go through.
+GetStudent(fromDB)
Scott P
“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
|
|
|
|
|
Hi, can anyone tell me what the ?? operator is for in C# ?
Thanks
|
|
|
|
|
It's a conditional statement where if the left hand side of the expression is non-null then it is returned, otherwise the right hand side is returned.
ex:
string value = GetSomeValue();
string result = null;
if (value == null)
{
result = "value is null";
}
else
{
result = value;
}
is the same as
string value = GetSomeValue();
string result = value ?? "value is null";
MSDN[^]
|
|
|
|
|
|
Hello
I have created my own event and delegate, they look like this:
public delegate Answer delegateCallResponse(Request req);
public event delegateCallResponse eventCallResponse;
the Request and Answer is 2 struct which contain a few strings/ints.
I got a method to handle the event, which look like
public Answer ans = new Answer();
private Answer OnEvent(Request req) {
FillRequest(req);
while (!ans.filled) { Thread.Sleep(1000); }
return this.ans; }
the ans.filled is a bool indication whether the information is filled or not.
My problem is that the Answer can take a while to get filled and the code as it is now, will make the mainthread sleep thus making the GUI unavailable for some time.
Is there a way to run the event in a thread? or just another way to make it wait than use the while function?
//QzRz
|
|
|
|
|
Use an Asynchronous method call to run FillRequest : Asynchronous Method Invocation[^]
then instead of looping waiting for ans.filled to be true you can set up a callback for when the function finishes.
|
|
|
|
|
If your event is in a class, you can create a method in that class that invokes the event asynchronously. Specifically, you can do:
<br />
ThreadPool.QueueUserWorkItem( delegate { <br />
if(eventCallResponse != null) {<br />
eventCallResponse(req)<br />
}<br />
);<br />
|
|
|
|
|
I have a DataGridView that has a DataTable set as the data source. When I add a row to the DataTable, it does get added to the grid but it is followed by a null row that sits between the row I just added and the next new row. How do I prevent this bogus row from appearing on the data grid?
|
|
|
|
|
Often when there is a null row there is an error in the code that is adding rows to the DataTable. I would check that logic.
If you would rather apply a hack than a fix to the error you can capture the Data Binding events for the DataGridView and manually remove the null records.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
You pointed in a good direction but I still don't know why this is happening.
I checked the row added event on the grid and sure enough, when that is getting fired, there is an additional null row in my DataTable which is affecting the grid. When the new row in the DataTable gets committed, the null row disappears from the DataTable but the grid hangs on to it.
I can't find any problems with the logic that adds the row to the DataTable so I decided to loop backwards through the grid and get rid of all rows in the DataGrid that do not exist in the DataTable.
|
|
|
|
|
Hello!
I have a LOGIN form with a combobox from which you can select the username. The combobox is bind to a sql table.
Also, my form contains a button "Add user" -> this button allows you to add new users through a new form where you can introduce all the data necessary about this new user. When i press OK in the Add user form, this closes and I want to see my combobox in the LOGIN form refreshed. How do i managed to do this?!
I've tried in 15 million ways to do it but withouth success:
- by using combobox.Update()
- by using usersTableAdapter.Update(fixedAssetsDataSet)
... and some other ways. I've deleted the code and I can't do any copy paste here now.
Pls help me! Suggest me a right way to refresh a combobox that is bind to a table.
10x
|
|
|
|
|
you can add a handler to the Closed event of the add user form that calls the bindComboBox function. before you do form.show you'd have form.closed += new eventhandler ect... calling update on a data adapter simply tells the adapter to update the table in the db with any changes that have happened to its data..not the other way around. Unless the stored update command has a select appended to it to return the new result set of the initial select query.
to summarize you'd need a function that loads the data to the comboBox (be sure to clear its items before you update it again or the items could duplicate), and in the btnAddUser_Click event you just add a new event handler to the AddUserForm.Closed event that will then call your function that loads the comboBox...i dont know if this is the best way to do it, but its probably the simplest.
|
|
|
|
|
You don't bind controls to the database table. You bind them to a copy of the records retrieved from that table. In order for you to see the changes, you have to requery the database to return the updated records and rebind to the new copy of the records.
|
|
|
|
|
Hello
I wanted to use a masked text box for some trivial need in data entry :
Limit to some allowe char
Example :
"YN<space>"
or
"X"
or
"AKLV"
But such trivial thing doen't seems to be possible with maskedtexbox or at least not good documented !
Does anyone have an idea how to do this with csharp
Obviously I can probably manage keyboard event to do this.
But in such case I will write my own maskedtextbox to replace this poor one !
|
|
|
|
|
Handle the Text-Changed event, and just check the string that's in the box.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank a lot John
I will do so
But I realize now that the use of masked text box is very limited
I don't even need a masked text box to do that !
I can't believe that they don't even think for such need
Use a regular expression in the mask for example !
|
|
|
|
|
Given your examples, I'd say it would be impossible to build a mask for that. The best you could do is to force all-uppercase alphabetic characters, but you'd still have to control which characters and how many in your code.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello John
I don't agree with you
It is impossible with the sad actual masked text box
But it would be very easy in the concept of such control to provide those feature
At least allow regular expression !
20 years ago using DOS interrupt I made a full masked screen editor much more powerfull that this poor maskedtextbox
|
|
|
|
|
The masked textbox sucks. Handle the key pressed event in the normal textbox, then reject keypresses you don't want from there.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
He's not going to listen to you. He built a DOS-based masked edit thing that's much better than the one in .Net (his claim, not mine). The absurdity is that if he's got the skillz, why the hell is he in here asking how to do it?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi
I am working on a project in which I need to NUnit testing. To do that I need to write tests for each class. I am trying to automate that process.
1. How to know names of public properties of class in .Net dynamically?
2. I am also looking for property types to set some default values.
3. There might be nested classes also. I am wondering how to traverse that nested tree?
Please advice. Thanks
Pankaj
|
|
|
|
|
|
I'm sure if you look around you'll find something that already exists to do this kind of job.
|
|
|
|
|
Using LINQ because it's so much easier...
1) How to know names of public properties of classes in .NET dynamically?
var properties = yourType.GetProperties().Select(p => p.Name); 2) Property types
var properties = yourType.GetProperties().Select(p => p.PropertyType);
var instance = Activator.CreateInstance(properties.First()); 3) Nested classes
var childClasses = typeof(Program).GetNestedTypes().Select(t => t.Name);
Note you can retrieve these without LINQ just forget the .Select(...) pattern, but you asked for names which implies strings so I used LINQ to extract the names rather than a loop.
|
|
|
|
|
Hi Everyone,
I'm running into a major problem with the combobox created by bestcomy. I also posted a comment on that article but its also very urgent so I thought I would try here as well. I recently had to re-install VS studio 2002 on my laptop and the code that I had to run the combobox created by bestcomy is no longer working. I'm getting this error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Method LoadPostData in type Bestcomy.Web.UI.WebControls.ComboBox from assembly LoadPostData does not have an implementation.
Source Error:
Line 187: <td class="heading" width=135px>Central Office:</td>
Line 188: <td width=220px>
Line 189: <bestcomy:ComboBox id="ddlCO" runat="server" Width="120px" AutoPostBack="true" ></bestcomy:ComboBox>
Line 190: </td>
Line 191: <td>
Has anyone seen anything like this before? Any help would be greatly appreciated. thanks!
|
|
|
|