|
bthumber wrote:
Can I create a file store the names in it, then compare want is in the file to to want the user types in the textboxes?
Yes, if you have a specific question in terms of C# feel free to post it.
- Nick Parker My Blog | My Articles
|
|
|
|
|
The next question is how do you compare those two strings?
|
|
|
|
|
bthumber wrote:
The next question is how do you compare those two strings?
Read about the String.Compare[^] method.
string s = "Nick";
string t = "Parker";
if(string.Compare(s, t) == 0)
Console.WriteLine("Equal");
else
Console.WriteLine("Not equal");
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello, I'm creating a slider-like control based in UserControl. Since the UserControl can't receive keyboard events (At least not that I manage to catch), I use a button as the slider handle since that can receive focus (I want to be able to run the slider up/down with the keys that's what I need the key focus for...)
First I tried listening to the KeyDown event from the button, but that doesn't get fired, only the KeyUp.. Has it something to do with that the button filters away these events and fires Click instead?
So I grab the button and check what messages it receives with spy++, and it says both WM_KEYDOWN and WM_KEYUP (repeated WM_KEYDOWN when key is held down as would be expected). So I override the button and it's wndproc to listen for these events, and also override the onpaint to get rid of the 'click' effect that I don't want.
BUT: the wndproc doesn't reveice any WM_KEYDOWN (0x0100) messages. So where are they going and how can I get them? Is there some kind of preprocessmessage-like function that receives and filters these events?
Or is there another control I can override instead of a button, that can get keyboard focus. Also, the button still has it's click behaviour that I don't want...
Can anyone help me with the right way to go??
|
|
|
|
|
A UserControl is for composite controls (i.e., controls made-up of other controls). It's not really a good base class in this case, and is designed to receive notifications from its children.
There are lots of articles here on CodeProject about custom slider controls. I recommend taking a look at some to get some better ideas (without going into a long, unnecessary discussion here) to help you along.
http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=slider[^]
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've got a custom control (button using rounded .gif image with transparent corners) on top of a panel. The panel has a .wmf file as its background image. When I place my control on my panel the background COLOR of the panel shows through my transparent corners instead of the background IMAGE of the panel. If I make the panel's background color transparent the background color of the form shows through the corners.
Is there any way to force the panel's background image to show up in the transparent sections of my control?
thanks!
Deanna
|
|
|
|
|
A little more info... In my control's OnPaint I'm trying to clear the background using :
g.Clear(Parent.BackColor); where g is my Graphics object
I'm wondering if that line is incorrect.
|
|
|
|
|
The best way is to use clipping regions. Transparency is only supported in Win2K and newer (flavors of Windows NT only; i.e., Windows ME does not support transparency), so if you want to support all .NET-supported Windows platforms, use clipping regions.
You can do this a number of ways, such as overriding OnPaint and setting PaintEventArgs.Graphics.Clip to a Region that contains only the portions to draw. You can construct an adequate Region using the GraphicsPath class in the .NET BCL.
Clipping regions is how most applications handle non-rectangular windows (controls are windows, too). It works on any Windows platform.
You can find a nice little library to assist you - even graphically in VS.NET - written by a Microsoftie at http://windowsforms.net/articles/usingregionmastercontrols.aspx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
i have developed a web service and it needs load a certificate from disc (i am using CAPICOM). In that moment the program throws a FileNotFoundException. I know that this operation uses the temp files of winnt so i have tried succesfully to create a file there from the ASP application. What´s happening then? How can i solve it?
I have read that the problem can come from XmlSerializer...but i find it very strange.
Thanks a lot.
PD: hey Heath...i am not pelos, it is just coincidence!
|
|
|
|
|
What I said to pelos still applies, though: quit using the CAPICOM interop assembly. Why marshal and use .NET-unfriendly APIs (more so than what's in the BCL, at least) when .NET can only load X.509 cert files and PKCS12 structures from disk?
The problem here is that ASP.NET Web Application (in which XML Web Services run) have additional restrictions (especially in .NET 1.1 and newer) and don't always use the same environment as assemblies loaded with the executable loader in Windows. Additionally, ASP.NET - by default - runs under the restricted user ASPNET, though you can configure this to run as SYSTEM (extremely bad idea) or as another user of your liking (has to then use a coded password in the machine.config or root Web.config file, though).
Files don't also resolve the same as they would in web applications. Be sure to use MapPath (several classes expose this, like the HttpServerUtility and the Page classes) to map the file to a physical path. The virtual path - depending on a number of factors - won't map to the right file path.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ReSharper is an add-in for Microsoft Visual Studio .NET 2003™ that brings intelligent C# coding assistance, real-time error highlighting and quick fixing, and advanced refactoring features to this popular development platform.
ReSharper provides C# developers with many of the same powerful productivity-boosting capabilities that thousands of Java™ developers worldwide have come to rely on every day with IntelliJ IDEA.
To learn more check out: http://www.jetbrains.com/resharper
|
|
|
|
|
before you try that tool , please see
http://www.codeproject.com/lounge.asp?msg=889398#xx889398xx[^]
(for your own sake)
some other small notes about the addin
it increases loading time for your projects with , well lets say 5000% or so
and the template system is nothing compared to the "quickcode" addin (the only addin i personally use nowdays)
//Roger
|
|
|
|
|
Hi people,
Intro:
The modem on the server is init'ed to pickup the line after first RING (ATS0=1). Another modem calls, performs some actions, informs the server that it is going to disconnect, and disconnects.
After the server has received the info msg about disconnect, it sends "+++ATH" to the modem and waits for "NO CARRIER". After that it re-opens the connection with the COM port, re-init'ing the modem.
No TAPI here, just plain AT commands.
The problem:
The disconnection scenario works for some modems, and doesn't for others. The server application hangs up while waiting for "NO CARRER", i.e it never receives this message. Incoming calls are not handled at this moment.
The qustion:
What is the correct way to re-open the connection with the modem, successfully hanging up the connection?
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
And this has to do with C# or even .NET how? It's not a problem with whatever language/framework/platform you use, but a problem with modem commands and should be asked in an appropriate forum (and CodeProject might not be the best place for more hardware-related questions).
To note, however, not all modems work the same. Win-modems (software-driven piles of rubbish) and firmware modems do work rather differently, and some modems may work differently than their counterparts (perhaps even by the same manufacturer). These are usually minor differences, but that could be your problem here.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
Heath Stewart wrote:
And this has to do with C# or even .NET how?
The application is written in C# and .NET. Also, a number of people (you being the 1st) have quite an experience in many fields, so I was hoping I can get a professional answer here in this very forum. Moreover, I do know about modem differences. I'm just stuck with this problem for the last 3 days. I tried quite a number of aproaches, but with now result.
Just thought somebody here has met the same challenge.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
Serge Lobko-Lobanovsky wrote:
The application is written in C# and .NET.
Like I said in my previous post, this doesn't matter. Whether you wrote it in C# (or any other language targeting the CLR), C, C++, Perl, or any other language, the problem would be the same. This forum is for C# questions. Even ASP.NET questions written in C# (that have to do with ASP.NET issues) are redirected to the ASP.NET forum (it's more specialized).
You may have a slight chance of finding the answer here, but you'll have a much better chance by using google to find some modem forums, mail lists, or newsgroups. You'll have much better success there.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You may need a comma after the "+++" Escape Sequence command. Many modems expect a pause at this point. Each modem manufacturer interprets the AT commands somewhat differently and it is sometimes difficult to find a command that will work for all modems.
I recommend that you perform a Google search using terms like: "AT Command", Reset, Escape, and DTR.
If you know the manufacturer of the modem chipset (like Rockwell or U.S. Robotics) you can go to their website and get the AT Command Document that explains exactly how their AT Commands work.
For your purposes it may be better to reset the modem by dropping DTR (requires certain state set by AT&D command), but is takes less time. (Check me on that.)
Regards,
|
|
|
|
|
I'm looking for a way to force an open dialog to display the files in thumbnail view.
Is there a way to do this? I guess that is something you can set for each individual folder
when browsing in an explorer window (which is what the open dialog uses, isn't it?).
But is there a way to set this programmatically? And for every all folders?
I need it for opening images and it would be nice to get the thumbnail functionality so easy...
|
|
|
|
|
I want to call the bellow function every time the content(NOT ONLY THE COLOR) of richTextBox change
void rTBOnContentChanged(.....)<br />
{<br />
....................<br />
....................<br />
....................<br />
}
|
|
|
|
|
|
I thought to use the event TextChanged, detaching and attaching again(durring color changes)
Any other better idea ?
void rTBOnContentChanged(.....) <br />
{ <br />
.................... <br />
.................... <br />
rTB.TextChanged -= new EventHandler(rTBOnContentChanged) <br />
.................... <br />
rTB.TextChanged += new EventHandler(rTBOnContentChanged) <br />
}
|
|
|
|
|
That code would load the processor tremendously. The TextChanged event is fired very often and attaching and detaching event handlers is expensive.
Instead of doing that, just use a state variable. In your handler (and why are you using the same handler which would make changes to the text, thus calling the handler again in a loop), just check if a state variable (herhaps a bool ) is set or unset (true and false , respectively). When you change the color, set the state variable, when you're done making changes, reset it. The handler would check the state of this variable and conditionally execute.
State variables are used everywhere in some form or fashion, and would be best to use here.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much Heath Stewart.
|
|
|
|
|
Hello,
I'm trying to solve the following. I've got a couple of say Books, Videos, Magazines. The classes are contained in various collections (derived from CollectionBase, but this is actually not importand). Now I'd like to go and write a generic Loader, which will populate a Listview Control with the items in a Collection. E.g. we'd like to load the BooksCollection. Since I'm having not only three Element-Classes, but say 50, I don't want to write a Loader for each class on its own. I'd rather like to check what kind of public fields the class has got and add the appropriate columns and values to the Listview. Question is, how can I retrieve the public fields of a class at runtime. I guess it has got something to do with reflection, but this is like a big wide desert to me. Any starting point?
Thanks in advance,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Start by reading Discoverying Type Information at Runtime[^] in the .NET Framework SDK.
If I were you, however, write a little more elegant solution (still using either reflection or the ComponentModel, which is a little easier to use - see the class documentation for the TypeDescriptor for a starting point). Derive all your collections from a single base class (perhaps CollectionBase or some other base class that exposes a common base class for all your objects, which might define common properties - don't use fields - like ID and Name , for example).
Also define an Attribute -derived class for fields you want to be mapped to columns (perhaps with an optional column heading for better control) like so:
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
string heading;
public ColumnAttribute()
{
}
public ColumnAttribute(string heading)
{
this.heading = heading;
}
public string Heading
{
get { return this.heading; }
}
} As you're enumerating properties, only show properties attributed with that attribute in the ListView , optionally using the Heading for the actual heading text (in case the property name to heading name mapping wasn't the same). You could even define some sort of order with the attribute for additional layout capabilities.
This would be attributed on properties of the objects being collected, however. The collection is rather moot (you could have one that just accepts the base class of all the other types, for example).
As far as loading this information, that really depends on what you're loading it from. The collection could be written as a smart class that knows which types to create based on the information presented to it (the navigational tree in our flag ship product works this way). You could go a step further and use a provider pattern to modularize how that information is obtained (having ADO.NET clients to get it from a database, XML Serialization providers, etc.).
XML Serialization may also be a good idea to use. Read XML and SOAP Serialization[^] in the .NET Framework SDK for more information (you can ignore the SOAP information, as that commonly applies to Web Services and .NET Remoting and is just a particular grammar of XML).
There's a lot of things you could do, but it's important you understand the concept of polymorphism: types deriving from other types that can override some information, basically. Implementing a good object model can save you a lot of time and create a more elegant solution that is easier to change, extend, and understand.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|