|
|
Hi my friends. I'm a newcomer around here and I would like to ask for your help, if it is possible of course. My name is Dimitris and I'm from Greece, so I would appreciate any kind of answer. My questions are:
1)How can I create the following array in C#?
2)How can I sort the jobs according to the Johnson's algorithm?
JOB | PRINT(HOURS) | BINDING (HOURS) | 1 | 15 | 3 | 2 | 7 | 9 | 3 | 4 | 10 | 4 | 7 | 6 | 5 | 10 | 9 | 6 | 4 | 5 | 7 | 7 | 8 |
If you have any kind of code for the above questions, it would be the best for me
Thank you in advance
modified on Thursday, March 6, 2008 6:26 PM
|
|
|
|
|
Two ways seem possible to me ( well, three, but the third is nasty )
1 - create a datatable in memory
2 - this is probably easier - create a class called PrintJob or something that has three properties, and create a List<PrintJob> to hold your data.
Now, I have no idea what Johnsons algorithm is, but I know you can write a class or an anonymous delegate to provide custom sorting on a list.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
DIMITRIS OLGA wrote: How can I create the following array?
It looks like you used HTML.
DIMITRIS OLGA wrote: the Johnson's algorithm
That depends on the size of your Johnson.
|
|
|
|
|
I'd go with Chris G's option 2. But you could also use a 2D array (perhaps his option 3?), although it wouldn't be great for readability... and lots of people i know don't seem too fond of the multidimensional arrays.
I also don't know what Johnsons algorith is either. All i know of the top of my head is the trusty old bubble sort.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
That was my option 3 - the issue is that the data becomes loosly coupled and loosely defined.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi friends, I am trying to move a control on my form when the control is selected and being moved on the screen. The control is moving but the problem is that it's leaving its instances behind while i am moving on form. I don't want to show its skin image. What i want if i move my control from point A to point B i don't wanna calcuate its location in between. How can i show a nice move from Point A to B without regenerating on every location. thanks I shall appreciate
public void ShapControl_MouseMove(object sender, MouseEventArgs e)
{
if (isShapSelected)
{
Location = new Point(e.X - _mousePointed.X + this.Left, e.Y - _mousePointed.Y +this.Top);
}
}
public void ShapeControl_MouseDown(object sender, MouseEventArgs e)
{
isShapSelected = true;
_mousePointed = new Point(e.X, e.Y);
}
public void ShapeControl_MouseUp(object sender, MouseEventArgs e)
{
if (isSymbolSelected)
{
isShapeSelected = false;
}
}
|
|
|
|
|
The real issue is not this code, it's the code that does the drawing. How do you draw your shapes ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Thanks for answering but I am controlling my own paint method and have override the OnPaint mehtod.
|
|
|
|
|
Hi, all;
(Using VS 2008, Win XP Prof SP2)
I was updating a spell-check control that used the MS Word spellchecker when I came across that for .NET 3.0 and above, the RichTextBox (and the regular one, too) have real-time spell checking.
After adding the WPF reference and the System.Windows.Cotrols namespace, I still can't get anything but an error when I try to enable the feature via:
richTextBox.SpellCheck.IsEnabled = true;
Even though its listed in the documentation for the RichTextBox control, SpellCheck is not considered a member if the class.
Much searching and I found this reference: http://msdn2.microsoft.com/en-us/library/ms788728(VS.85).aspx for "How to: Enable Spellchecking in a Text Editing Control" which gives an example - seems simple enough but it just won't work. See Below
Has anyone gotten this to work?
Thanks,
Balboos
(The above link will display the following:
<code>using System;
using System.Windows;
using System.Windows.Controls;
namespace SDKSample {
public partial class SpellCheckExample : Page {
public SpellCheckExample() {
StackPanel myStackPanel = new StackPanel();
//Create TextBox
TextBox myTextBox = new TextBox();
myTextBox.Width = 200;
// Enable spellchecking on the TextBox.
myTextBox.SpellCheck.IsEnabled = true;
// Alternatively, the SetIsEnabled method could be used
// to enable or disable spell checking like this:
// SpellCheck.SetIsEnabled(myTextBox, true);
myStackPanel.Children.Add(myTextBox);
this.Content = myStackPanel;
}
}
}</code>
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to go away?" - Balboos HaGadol
<div class="ForumMod">modified on Thursday, March 6, 2008 3:47 PM</div>
|
|
|
|
|
Yup - it works for me. Try to use System.Windows.Controls.RichTextBox as the source rather than the WinForms version, as this is a WPF feature.
|
|
|
|
|
Thanks for the tip. Alas, in this case, it opened one of those daisy-chains (or certainly seemed to), where I added more references, and each change required more changes.
I created a WPF project, directly, hoping for a roadmap to what's maissing - and became a bit cross-eyed at how differently the 'code' was presented. Clearly, I've a hefty amount of study to do.
My hope was to simply add another namespace (&etc), and access the WPF objects.
Nonetheless, you set me off in the direction so that I don't keep spinning my wheels on this.
|
|
|
|
|
Friends,
Few months back, i've noticed a feature in Visual Studio with which we can generate HTML documentation of our classes. I don't know that which version of Visual Studio i've seen this feature or whether it is for C# or C++. Please tell me that from which menu item i can invoke this option ?
Imtiaz
|
|
|
|
|
Imtiaz Murtaza wrote: feature in Visual Studio with which we can generate HTML documentation
Are you kidding[^]?
led mike
|
|
|
|
|
You want to look into Sandcastle and the /doc operation in building your app.
|
|
|
|
|
Hello I have a datatable fill by a query
That datatable is the datasource for a combo
I try to programmaticaly change the Value on an Item in a row of that datatable
dtt.Rows[i].ItemArray[1] = addrID;
I got no error but the value of
dtt.Rows[i].ItemArray[1]
Remain unchanged
addrID is an int
What is wrong ?
|
|
|
|
|
baranils wrote: I try to programmaticaly change the Value on an Item in a row of that datatable
Are you working from a book or tutorial or article that told you to do it that way?
led mike
|
|
|
|
|
Why such question ?
No I'm working from my own, learning quickly and trying to find as much information as I can everywhere, in my mind too.
But with some try and error of course
So...
do you have a solution ?
|
|
|
|
|
baranils wrote: do you have a solution ?
Yes, use a tutorial or article or book. There are many articles here on CodeProject.
baranils wrote: Why such question ?
Good question, how about, because I know what I am doing and you don't? You like that reason?
led mike
|
|
|
|
|
Try
dtt.Rows[i][1] = addrID;
You can also use the ["TheNameOfTheColumn"] instead of [1], like so:
dtt.Rows[i]["AddressID"] = addrID;
"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 You John
Yes I got it and you are right : using the field name avoid confusion or even mismatch when the user reorder column in a datagridview for example
However indexing using an ordinal can be faster and usefull sometime
|
|
|
|
|
baranils wrote: However indexing using an ordinal can be faster and usefull sometime
It may be a little faster, but not nearly as maintainable for the guy that follows you into the 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
|
|
|
|
|
Right !!
|
|
|
|
|
Is there any other way of updating forms in a thread safe way apart from the delegate/InvokeRequired trick?
I'm working on an app (RSS Reader) which has a separate thread for checking if new items appeared and updating context menus accordingly, can I acquire some sort of lock to a control or do I have to create UpdateContextMenuItem(ToolStripMenuItem menuitem, ToolStripItem subitem)-esque methods for each and every action that I may need to perform? I'm new to C#/.NET, and despite initial bias I was quite impressed how clean and well-designed it is, until now.
TIA,
Greg
|
|
|
|
|
Jergosh wrote: I'm new to C#/.NET
What about Object Oriented Programming and/or Design Patterns, are you new to those as well? What is your background?
Jergosh wrote: apart from the delegate/InvokeRequired trick?
Why is that a trick? It's an implementation of inter-thread communications, do you know of some way to communicate between threads that doesn't involve communicating between threads?
led mike
|
|
|
|