|
tlbimp.exe and aximp.exe do the same thing as referncing ActiveX controls in the Toolbox and as references from Add Reference - they both generate interop libraries (RCW's). That is the recommended practice.
Even if you add AxShockwaveFlashObjects.cs to your project, you still need to add the interop library Interop.Flash.dll (or whatever it is called) to your project. aximp.exe creates to interop assemblies - one that contains the definition of any ActiveX controls that derive from AxHost , and one that contains the RCW for the typelib (type library). Both are required.
If you want do it the manual way, you must still reference the latter interop library mentioned above. You're duplicating code, though, if you reuse the ActiveX control in other projects. That's why signing the interop assemblies and using them across your projects is a much better idea - granular control.
If you want the control you've compiled into your assembly to be in the toolbox, then after you've compiled your project custom your toolbox (right-click on the toolbox) and browse to your assembly (it won't show up in the list unless you've added the necessary registry key, and for a project in development that's silly - especially in the target directory; at least copy it to a common path). When you click OK after browsing for it, you can check which components (including controls) you want to add to the toolbox.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is there a pre-existing class/method in .NET or does anyone know of code that will count the number of unique format items in a string (i.e. how many parameters are required.)
In other words, passing "This is {0} a {1} test {0} string" to this method would return 2. (If I could also verify that the string is well formatted, that would be a big plus.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote:
In other words, passing "This is {0} a {1} test {0} string" to this method would return 2.
Ok, I just threw this together but it does the trick. Try the following:
using System;
using System.Collections;
using System.Text.RegularExpressions;
public class Test
{
private int GetFormatItemCount(string s)
{
ArrayList al = new ArrayList();
Regex r = new Regex("{*[0-9]*}");
Match m = r.Match(s);
while(m.Success)
{
if(!al.Contains(m.Value))
al.Add(m.Value);
m = m.NextMatch();
}
return al.Count;
}
[STAThread]
static void Main()
{
Test t = new Test();
string arg = "This {0} is a {1} and {2} and {0} for good measure.";
int count = t.GetFormatItemCount(arg);
Console.WriteLine(count + " items in string.");
Console.Read();
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I was thinking of this approach, but hoped something was built in that I was missing. This will do for now.
(Note: this fails if the string has double braces like: "This {{0}}")
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote:
(Note: this fails if the string has double braces like: "This {{0}}")
Why are you looking for something like this? I spent 3 minutes on it, there are other areas in which that function could fail as well, if the string were null for example. This should give you a starting place though.
- Nick Parker My Blog | My Articles
|
|
|
|
|
It's for a tool we're prototyping to help third party writers translate strings. As I said, I'd considered the RegEx option, but hoped there was a method built into .Net that could also validate the items as well.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
This forum is to help educate posters about concepts, not provide end-to-end solutions. Sample code is just that - sample code. If you want complete solutions, try browsing or searching the articles, but keep in mind that many of those are just samples as well.
To answer your original question, no there is nothing built into the BCL that does this for you, nor should there be - it's simple pattern matching.
If you want to see how Microsoft does it in StringBuilder.AppendFormat (which String.Format and Console.WriteLine ultimately use), then I suggest you open mscorlib.dll in ildasm.exe from the SDK to view the IL, or download a decompiler (keeping in mind that decompilation is a best-guess solution) like .NET Reflector and view the decompiled code in a supported language of your choice (currently C#, VB.NET, and Delphi are supported).
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart wrote:
To answer your original question, no there is nothing built into the BCL that does this for you, nor should there be - it's simple pattern matching.
I disagree. Checking whether a formatable string is well formed should be built into the BCL. On more than one occasion, I've had to do something similar for C/C++ projects. I suppose this would be an excuse for an article. (Counting the number of unique format items would be a side effect of this process.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hello everyone,
it is just me with another question:
I am using a TCP socket and asynchronous methods to implement a listening server, which will then re-format and forward these request to a SAP R/3 system.
All this is done in a C# Windows Service with attached SAP .NET connector.
I have everything up and running, BUT I am not sure if it will continue running given that the data is - at least on the listen server side - passed through Encoding.ASCII.GetBytes and Encoding.ASCII.GetString.
I understand that Windows uses UTF8 (ANSI). Is that right?
Now, I BELIEVE that I should use Encoding.UTF8.GetString AFTER receiving and Encoding.ASCII.GetBytes BEFORE sending when communication with my client?
My client is an IBM-Mainframe, complete with terminal-emulation and the dreaded (at least by me) EBDIC. I have been told that the Mainframe auto-magically does an EBDIC-TO-ASCII Conversion before sending to me and ASCII-TO-EBDIC after receiving...
What I am afraid of: I get a package which instructs me to perform a search on the SAP System. I receive in ASCII and do no conversion. The String contains an Umlaut (ä,ö,ü) and I get no result, because SAP uses UTF8...
The same way around, I forward data to the mainframe and since it comes out of my program, its UTF8. The mainframe then is supposed to store this data, checks if its already there and finds its not, so he creates a new table - and it is there, just as ASCII.
If you can sort this out, please feel free to give me some hints.
And dont make em hint* = null
Cheers
Sebs
|
|
|
|
|
Windows uses whatever encoding you tell it to, except that Windows in general (as opposed to Windows NT-based platforms, which include Windows NT 4, Windows 2000, Windows XP, Windows 2003, "Longhorn", and beyond) doesn't support Unicode (that means Windows 95, 98, and Me don't support Unicode without the Microsoft Layer for Unicode linked against your applications). You can still write-out Unicode files from your .NET applications, but no APIs on Windows will understand them.
Encoding.UTF8 is nice because ASCII is still supported (the 7-bit characters) and it's still single-byte unless a trailing byte is necessary (which is described in the upper 128 bits of the byte, so 0x80 to 0xff).
Note that there's really no reason to convert an ASCII stream to UTF8 unless a certain codepage is in use. In such a case, the Encoding.Convert method is handy.
But the encoding you should use is whatever the SAP system supports. If SAP supports UTF8, then use UTF8. A nice way to encapsulate this behavior is to write your NetworkStream in a TextReader and a TextWriter like so:
StreamReader reader = new StreamReader(networkStream, Encoding.UTF8);
StreamWriter writer = new StreamWriter(networkStream, Encoding.UTF8); Now you can read and write strings that will be decoded and encoded (respectively) and send through the NetworkStream as bytes automatically.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have seen and tried your RowSelectorColumn control from Andy Smith to add Radio button or Check box control as selection column.
But i guess there is some problem with it.
See the problem goes like this. If you can help me out in this it would be great.I want some same functionality as you have provided but as you have extended DATAGRIDCOLUMN, I m extending DATAGRID and as per your example developer has to add
<mbrsc:rowselectorcolumn allowselectall="True" selectionmode="Single">
at design time. But what i m trying out is that if developer selects property either Single or Multiple, My datagrid will automatically add this column on "OnInit" of my Datagrid or CreateChildControl method.
The problem is if i add this on either of the event and if i DONT ADD any further column it works fine but if i try to add ONE MORE COLUMN from designer (from Property Builder) it adds SelectedIndexes="Int32[] Array" as a property and it gives error
<mbrsc:rowselectorcolumn allowselectall="True" selectedindexes="Int32[] Array" selectionmode="Single">
The same this is happening with your control as well.
Now if i remove SelectedIndexes="Int32[] Array" from the HTML and run it gives me TWO RADIO button columns instead of one.
Now to solve this i converted this SelectedIndexes property to method but problem still persist. It still adds two radio columns.
I have tried to check if column adready added using BOOL variable but it doest work as OnInit fires every time and value for BOOL value would be FALSE alway.
Can you pls help me where i doing mistake or how to resolve this problem. I m stuck with problem and its very fustrating that i dot see any logical solution of this.
Thanks a lot in advance.
Bhavesh Amin
|
|
|
|
|
If you have questions or comments about a specific article, then you should ask in the message board at the bottom of that article - that's what the message boards are there for. This forum is for general C# and related .NET questions.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Does anybody know how to set the color of ListView columns???
I need to set the whole columncolor and not only the background color of a
subitem.
Can somebody help me
Thanks
00ason00
|
|
|
|
|
Unfortunately there's no such thing as ColumnColor in the built-in ListView.
If you want to achive this effect than you's have to set the color of each n'th SubItem (after setting UseItemStyleForSubItems to false for the ListViewItem ).
mav
|
|
|
|
|
Hy everyone!
I do have a problem with my application:
I do want to change the appearence of my application if the user wishes to. I do have a Windows.Forms and two User.Controls which are displayed. The user is able to select items from a combobox which might cause the displayed layout to change.
When I do so then there is some kind of flickering. So I thought of freezing the layout until the changes are done. I did the following
<br />
this.SuspendLayout();<br />
this.ResumeLayout(false);<br />
well but the flickering is still there. The one control is a "single" control but the second one consists of one or more being placed on top of each other with the visibleoption displaying one at a time.
Is the "overlaying" of the controls the reason?
Because I thought as long as I do set the Windows.Forms to SuspendLayout everything in there is freezed until I do call ResumeLayout. But I am not sure if this includes the controls as well, which are added or deleted dynamically. Or do I have to suspend and then resume every element (meaning the controls) as well?
Does anyone of you have an idea, what might be wrong in here?
Thanks!
Stephan.
|
|
|
|
|
Try placing the control in a panel. You can avoid flickering by hiding the panel and showing it when the new controls have been added:
<br />
panelContainer.Hide();<br />
panelContainer.Show();<br />
You can put a "Please Wait..." label under panelContainer , so that the user sees a message until the control are visible again.
|
|
|
|
|
Your question is very vague. What is GetRow() supposed to be doing for you? What are your trying to do? And what do you mean by "another Utility Functions"?
You're going to have to be alot more specific about what your trying to do and the problems your having.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Not really a programming question, but is it possible to have Visual Studio put the project files with BuildAction set to "Content" (for example, an XML or INI configuration files, or HTML pages) to the /bin/Debug /bin/Release folders automatically? I have VS.NET 2003 Pro here, and I'm talking about Windows Application / Console Application projects.
It would be nice to have these files as a part of the project and not need to copy them manually to /bin/Debug everytime I change them, but I just can't figure out how to achieve this. Is there a plug-in for this, or can VS do this automatically?
Thanks for any ideas,
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Yes I have see this too! And reading the docs it would assume it should copy it, but it doesnt...
Best is to setup a post build event and copy the files, tedious, but at least it will work (i wonder is MS will fix that silly little "editor" that doesnt work at all?)
HTH
top secret xacc-ide 0.0.1
|
|
|
|
|
Yes, it helps, thanks for the tip! At least we have something that works.
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Actually, "Content" is for when you build setup projects in VS.NET. If gives you the choice of output, content, source, and (something I can't remember) files from projects you select. This establishes a dependency on the code project for the setup project and automatically copies the files from that category. Nifty, but what you and the original poster were talking about would be nice, too.
I recommend going to http://lab.msdn.microsoft.com/vs2005/[^] and add a request if one doesn't exist already.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi, I am using a ComboBox with a DataView as a DataSource. When I load 0 Value into the ComboBox (which Does not exsist) or set The Selected Index to -1 the ComboBox shows a different Value.
for example after this line:
this.comboBox_currency.SelectedIndex = -1;
sometimes the SelectedValue will be null and other times it will be {2} or any other value.
|
|
|
|
|
You may need to make certain that you are not trapping the SelectedIndex_Changed event or something similar. That will sometimes burn you. One approach I took was this:
...
bool IgnoreChangeEvent = false;
...
if (condition)
{
IgnoreChangeEvent=true;
box.SelectedIndex = -1;
}
...
box.SelectedIndex_Changed(object sender, EventArgs e)
{
if (IgnoreChangeEvent)
{
IgnoreChangeEvent=false;
return;
}
... determine if action is needed
}
This signature left intentionally blank
|
|
|
|
|
I have read some source codes and I've seen that the BeginUpdate method is used before adding items to a TreeView, EndUpdate after adding items. But when I don't use the BeginUpdate and EndUpdate, the items are also added to TreeView.
Can you tell me the differences beetween using and not using these methods. Thank you
Robe
|
|
|
|