|
I have a ListView control in my application which allow users to add new items to the list and later modify the label of the item displayed in the list. I set the LabelEdit property to true to make the ListView control editable.
Now, the problem is that when users add a new item to the list, they have to "double click" on the ListViewItem in order to turn it into the editing mode and then change the value to whatever they want. What I want instead is to put the the item into editing mode right after a new item's been added without requiring the users to double click on the item.
I've been googling and searching in MSDN for hours but without any luck. Could anybody point me to the right direction?
|
|
|
|
|
After adding the ListViewItem you can call ListViewItem.BeginEdit , which places the item in edit mode.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Does anyone know how to implement a class that can forward a port ?
it should for example when a http request on a port of the pc who is running the application forward is to a pc that is running a webserver and send the data back to the pc who send the http request.but i should be able to forward any type of connection like when you forward any connection to pc on a network using your router. so also ftp,vnc and such
|
|
|
|
|
You've just described a firewall. Is there some reason why you couldn't use something off the shelf?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a datagrid that has a checkbox column. I want to know if it is possible to group a datagrid, so that the checkbox would only show up next to order numbers, and the person would not have to click on each checkbox next to a child row of that order. Once they click on the checkbox next to the order number, that would affect any child row of the order number.
Scott Moore
|
|
|
|
|
If you have established a DataRelation between the parent and child DataTable s - and presumably you have since you are either using parent/child navigation or master/detail DataGrid s - then you can handle an event when data changes for a row, get related child rows, and mark them all as being selected.
The easiest way is to have a boolean column for each of the parent and child rows of the DataTable s in question. After assigning your DataTable (or DataSet with the DataGrid.DataMember set to the table name, which I recommend) handle the DataTable.ColumnChanged event. When that's fired you get a DataColumnChangeEventArgs.Row that gives you the specific row. On that, call DataRow.GetChildRows - passing in the data relationship name (or instance) that relate the parent and child tables. That returns you a DataRow[] array that you can loop through and set each row's boolean column you want set.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Suppose I have a simple class called MyClass that contains nothing more than
an "int x" and "set" and "get" properties.
Now I create a WinForm1 with a text box and an "OK" button that will output MyClass' "int x" in a Message Box.
Question: Where in the project does "MyClass" go?
Question: Anything else I should know(namespaces etc...)?
--thanks
|
|
|
|
|
I would HIGHLY recommend picking up a book on C#. The questions you're asking are really beginner level. Also, your reference to "Anything else I should know?" would take an enormous amount of space in the forums to explain.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So you don't know where to put a user defined class in a WinForm,
project I take it.
I didn't know beginner questions weren't allowed, but thanks anyway...
|
|
|
|
|
Yes, I do. The problem is, there just isn't any one place to put them. Traditionally, class definitions should go into it's own files. What happens after that is FAR more material than anyone would want to put into a post.
The book recommendation is to answer al the basic questions and they make a very handy desk-reference while your learning the basics.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave- The proverbial "light bulb" just went on.
One obvious way- simply declare user defined class
within the Form namespace and then one can instantiate an object
within the code that will fire the event etc...
Apologize for the terse reply. I haven't done this stuff in over a year
and I'm trying to keep far away from the Console Window....
|
|
|
|
|
SkunkedWorks wrote:
I didn't know beginner questions weren't allowed
Beginner questions are allowed. However your questions were quite open.
SkunkedWorks wrote:
Where in the project does "MyClass" go?
Pretty much anywhere you like. As Dave said, a class usually goes in a file of its own. There is nothing to enforce this, it is just a convention that everyone uses. However, there are exceptions to the rule which would be better discussed in a good book on the subject. This whole area would probably take a chapter out of the book.
SkunkedWorks wrote:
Anything else I should know(namespaces etc...)?
Since we don't know what you do know, we wouldn't know where to start. This information would probably take the remainder of what ever book you get.
The types of questions that work best in a forum are those that only require a short(-ish) answer. Obviously, as you are a beginner you can't tell in advance the scope that your question is in, so don't worry too much about it. People will tell you when your question is best answered by reading a book, or point you in the direction of a relevant article on the subject - I've created articles here and have entries on my blog to point people to for common questions that arise over and over that take more time than a normal forum post would allow. This way I can be more help than I otherwise would have had the time to be.
I hope this is of some help and you are at least encouraged that people will try and help when they can.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Colin and Dave are right, one can only guess what you want, or link you to MSDN[^]. Reference and tutorials are there, but maybe not as friendly as a book. OTOH I have no book about .NET, most of things I've learned on the internet... but one must have enough time
Here is my guess:
class WinForm1: System.Windows.Forms.Form
{
...
private MyClass _mc;
...
}
This is only one of many interpretation of your question. Does it help?
David
|
|
|
|
|
hello my Article updated by myself if wants to benefit search for author Ahmad or search for xml guest book
Ahmed Erarslan
MCAD,MCDBA,MCP
MCSD.NET
|
|
|
|
|
Since you keep posting these update notifications, a quick review...
First, don't vote 5 on your own article. You come off patting yourself on the back, especially when this is not an "article." It's a few code snippets with no explanation of the theory and logic behind the code! Before you can call this an article, you've got a lot more work to do to explain what this is, what it does, the theory behind the code and why.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i've created a file .mfl.
I want by clicking of this kind of file run my own application and pass the path of the file at some internal function.
Someone can help me?
|
|
|
|
|
You need to set up a file association and you can do this programmatically by accessing the registry using the Microsoft.Win32.Registry and RegistryKey classes. Read Creating a File Association[^] in MSDN for more details.
If you plan on deploying your application, I suggest you create a Windows Installer project in your solution to install your project output files. You can create file associations in the product by following the direction in File Types Management in Deployment[^] in the Visual Studio .NET product documentation.
When a user double-clicks the file with your registered extension it is passed as the first argument to your Main function, so you could do something like in the following example:
class MainForm
{
static void Main(string[] args)
{
MainForm form = new MainForm();
if (args.Length > 0) form.OpenDocument(args[0]);
Application.Run(form);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
Hi! could any one tell me. How to take an array as a input parameter in method by web service? I have tried to many time but I got the error about primitive data type.
Thanks in advance.
|
|
|
|
|
|
Could be a lot of things...
Usually you mean how you interact with something...
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
You can read more about interfaces in the C# language specification at http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_13.asp[^].
As it says, an interface is a contract. If you implement an interface a caller knows that your implementation class supports certain methods, properties, and events (in .NET; other languages or framework interfaces may not expose all these things). This and extending classes are what allow you to use polymorphism in code, which helps you create plug-in application and many other application frameworks like COM/OLE (on which Windows is built), distributed computer models, and many other technologies.
So, you could have what's known as a class factory to generate classes that implement a certain interface so that you don't have to bind to a specific class at runtime:
public interface IPlugin
{
string Name { get; }
void DoAction(object context);
}
internal class PluginFactory
{
static IPlugin CreatePluginInstance(string name)
{
switch (name.ToLower())
{
case "helloworldplugin":
return new HelloWorldPlugin();
case "notepadstarter":
return new NotepadStarter();
default:
throw new NotSupportedException("No plugin found.");
}
}
}
public class HelloWorldPlugin : IPlugin
{
public string Name { get { return "Hello World Plugin"; } }
public void DoAction(object context)
{
MessageBox.Show("Hello, world!");
}
}
public class NotepadPlugin: IPlugin
{
public string Name { get { return "Notepad Starter"; } }
public void DoAction(object context)
{
string filename = null;
if (context is string) filename = context as string;
Process.Start("notepad.exe", filename);
}
}
internal class Example
{
static void Main(string[] args)
{
string name = string.Empty;
if (args.Length > 0) name = args[0];
IPlugin plugin = PluginFactor.CreatePluginInstance(name);
Console.WriteLine("Starting \"{0}\"...", plugin.Name);
plugin.DoAction(args.Length > 1 ? args[1] : null);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Please, I want to know how to assign colors to different regions in the gray scale image, based on the gray level of the region's pixels?
thanks,
--M.Sami
BASKOTA
|
|
|
|
|
Coloring a gray-scale image with any decent quality is not a straight forward color-assignment to luminescence process typically. To learn the details about how it's done professionally I recommend doing a search for something like coloring gray-scale images[^].
To actually implement this in .NET, you use the System.Drawing.Bitmap class. When dealing with pixel-by-pixel transformations you might consider calling Bitmap.LockBits , which locks the object in memory so it isn't moved around and gives you a BitmapData object you can use unsafe code to access pixels. Only do this if you're sure you're handling memory correctly and efficiently, and be sure to call Bitmap.UnlockBits when finished.
For a great overview of unsafe transformations of graphics in .NET - as well as safe transformations - read Christian Graus's article, Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^].
As an aside, try to steer clear of unsafe code in .NET. It is there for interoperability but requires special permissions and leaves your code unverifiable, which is a safety net for your users. That's part of what being "managed code" is all about.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi guys,
I have an edit box with text and want to set the focus to that edit box but putting the text cursor at the end of the existing string.
I am probably just being stupid here but I cannot find any reference to this in the Microsoft help. If you just set the focus to that window the cursor appears at the beginning of the existing text (I'm talking about using SetFocus here not clicking on the window with the mouse).
Can anyone shed some light on this. Any help much appreciated.
Richard
|
|
|
|