|
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
|
|
|
|
|
led mike wrote:
What about Object Oriented Programming and/or Design Patterns, are you new to those as well? What is your background?
I have experience with C, C++ and Python as well as have completed misc university courses (algorithms and data structures etc) but I don't see how that's relevant.
led mike wrote: 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?
I'd say it's less standard than just acquiring lock, doing whatever we like with the object and then releasing it. Less convenient as well if I want, say, clear a menu and populate it with dynamic content as I have to write several helper methods. Apart from that, replacing
menuItem.DropDownItems.Clear();
with self-made
ClearDropDownMenu(menuItem) isn't particularly object-oriented (or at least doesn't look as if it was). Could we please get back to my initial question?
modified on Thursday, March 6, 2008 3:15 PM
|
|
|
|
|
Jergosh wrote: I'd say it's less standard than just acquiring lock
How does acquiring a lock switch your codes execution context to another thread?
Jergosh wrote: Could we please get back to my initial question?
Your initial question appears to be based upon a misunderstanding of some of the things that are involved in the answer to your question. The direction of my posts was based on the idea that you might consider it of value to gain an improved understanding of these rather than just be given a "do this" solution. If that's not the case then so be it.
led mike
|
|
|
|
|
Hi,
accessing a Control must be done by the thread that created the Control, normally the main
thread a.k.a. GUI thread. So other threads must SOMEHOW pass the GUI access actions to the
main thread. There are basically two ways to do that:
1. the Control.InvokeRequired/Invoke pattern
2. otherwise passing sufficient data to the GUI thread and have it access the Controls
(e.g. prepare a collection with new data, and have it processed by a Windows.Forms.Timer,
which always ticks on GUI thread!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: There are basically two ways to do that:
1. the Control.InvokeRequired/Invoke pattern
2. otherwise passing sufficient data to the GUI thread and have it access the Controls
(e.g. prepare a collection with new data, and have it processed by a Windows.Forms.Timer,
which always ticks on GUI thread!
Most helpful, many thanks
|
|
|
|