|
Actually, I was referring to the comment in the discussion someone linked that said that only "primatives" could be declared as consts. The fact that Jeffrey Richter said that String was a primative (and I'm taking your word for it) would be incorrect, yes. The Framework supports that by what you saw (which, BTW, you don't need to use Boolean.ToString in Console.WriteLine , since it formats every argument - regardless of type - as a string anyway; see my article, Custom String Formatting in .NET[^] for a brief discussion, though the article's not about that so much).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I would say string is primitive as it is directly supported in the CLR. Decimal on the hand, is not.
top secret
|
|
|
|
|
Hi all...
I just back to my machine today morning after Easter vacation. Have gone thru all comments. Frankly, as of now, I don't have that much in depth idea about it to say something authentically. Thanks very much for all valuable inputs so that I can consider those to identify the truth.
rgds...mil10.
|
|
|
|
|
Hi everybody,
I visited a website about 4 or 6 months ago that was presenting a component for either .NET or COM that allowed to write Excel files programatically (not just automation, it was standalone: no need for Excel). I remember the component was quite cheap (or free, unsure) and not from one of the big component makers out there. It was pretty much one guy writing this component and sharing with others.
The problem is, I can't find the website anymore, nor do I remember the name of the thing. I bookmarked it but I deleted all my bookmarks about a month ago because I never used them (duh!)
Anyone knows what I'm talking about and can point me to the right direction? Google and Groups.Google didn't help.
Thanks a lot!
Carl
|
|
|
|
|
Try http://www.fpoint.com[^]. This is Farpoint Technologies, makers of Spread for COM and .NET, one of the best Excel-like controls that's been around for quite a while. It can open and write XLS files and handy many of Excel's embedded functions (like SUM, AVG, etc.). Many of the same features are supported, and it is relatively cheap (Spread for Windows Forms is $799).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm sure their component is nice, but at $800, it is really not in my budget.
The thing I'm looking for was either free or under $100... I don't remember exactly.
Thanks
|
|
|
|
|
It was easy to find this[^] after a quick search on the usual sites.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You may also want to have a look at XlsGen[^]. The price for a license starts around $10 USD.
--Jesse
|
|
|
|
|
GREAT!!!!!!!! That's the one I was looking for! I knew some CPIANs were smarter than me and didn't delete their bookmarks
Thanks again, this really helps!
|
|
|
|
|
Is there a c# version of this: http://www.codeproject.com/shell/shellextguide1.asp ?
Is it possible to do it in c#? Can anyone point me to a tutorial or even just briefly explain how to do it?
Thanks
|
|
|
|
|
This should get you started, so then you just have to implement the methods provided(just follow the code from the article
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class SHITEMID<br />
{<br />
int cb;<br />
byte [] abID;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class LPITEMIDLIST<br />
{<br />
SHITEMID mkId;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class LPCMINVOKECOMMANDINFO<br />
{ <br />
int cbSize; <br />
int fMask; <br />
IntPtr hwnd; <br />
[MarshalAs(UnmanagedType.LPStr)]<br />
string lpVerb; <br />
[MarshalAs(UnmanagedType.LPStr)]<br />
string lpParameters; <br />
[MarshalAs(UnmanagedType.LPStr)]<br />
string lpDirectory; <br />
int nShow; <br />
int dwHotKey; <br />
IntPtr hIcon; <br />
} <br />
<br />
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E8-0000-0000-C000-000000000046")]<br />
public interface IShellExtInit <br />
{<br />
[PreserveSig()]<br />
int Initialize(<br />
LPITEMIDLIST pidlFolder,<br />
IDataObject pdtobj,<br />
IntPtr hkeyProgId<br />
);<br />
}<br />
<br />
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E4-0000-0000-C000-000000000046")]<br />
public interface IContextMenu<br />
{<br />
[PreserveSig()]<br />
int GetCommandString(<br />
out int idCmd,<br />
int uFlags,<br />
out int pwReserved,<br />
[MarshalAs(UnmanagedType.LPStr)]<br />
string pszName,<br />
int cchMax<br />
);<br />
<br />
[PreserveSig()]<br />
int InvokeCommand(<br />
LPCMINVOKECOMMANDINFO pici<br />
);<br />
<br />
[PreserveSig()]<br />
int QueryContextMenu(<br />
IntPtr hmenu,<br />
int indexMenu,<br />
int idCmdFirst,<br />
int idCmdLast,<br />
int uFlags<br />
);<br />
}<br />
<br />
[Guid("30DA4710-4D8A-4753-981A-9D20D5790356"), ComVisible(true)]<br />
public class MyShellExt : IShellExtInit, IContextMenu<br />
{<br />
public MyShellExt()<br />
{<br />
}<br />
#region IShellExtInit Members<br />
<br />
public int Initialize(LPITEMIDLIST pidlFolder, IDataObject pdtobj, IntPtr hkeyProgId)<br />
{<br />
return 0;<br />
}<br />
<br />
#endregion<br />
<br />
#region IContextMenu Members<br />
<br />
public int GetCommandString(out int idCmd, int uFlags, out int pwReserved, string pszName, int cchMax)<br />
{<br />
idCmd = 0;<br />
pwReserved = 0;<br />
return 0;<br />
}<br />
<br />
public int InvokeCommand(LPCMINVOKECOMMANDINFO pici)<br />
{<br />
return 0;<br />
}<br />
<br />
public int QueryContextMenu(IntPtr hmenu, int indexMenu, int idCmdFirst, int idCmdLast, int uFlags)<br />
{<br />
return null;<br />
}<br />
<br />
#endregion<br />
}<br />
|
|
|
|
|
In an old project we are using the Crystal report viewer (CrystalDecisions.Windows.Forms) which was orginally version 9.1.5000.0 but we have updated to version 10 now.
If I look at the properties of this referenced assembly within Visual Studio .NET it shows version 10.0.3300.0 but when we build the app and look at the assembly information on the .exe file it still shows version 9.1 begin referenced.
How to update the assembly reference?
|
|
|
|
|
Rebuild your project or solution. This will clean intermediate files and rebuild the entire project or solution.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Can somebody please tell me how to use the "Item" property in System.Collections.SortedList class. I wanted to get and set the value field depending on the key.
Thanks
Raj
|
|
|
|
|
|
If you look at the documentation for the Items property, it says that it's the indexer in C# (the same as other lists' Items properties). This means you use it like this:
myList[key] = value;
value = myList[key]; You can use a key because a SortedList implement IDictionary , an interface for key/value collections. Mosts lists in the .NET FCL simply take an index (0-based, as with all .NET languages) in their indexer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for your reply. I am new to .Net. Trying to understand these properties. DO I have to override this property.
I am doing like this, but it doesn't work. In my Sorted list keys are of type string and value is of type int.
public override int Item(string myKey)
{
get
{
return mySrotedList[myKey];
}
set
{
mySortedList[myKey] = value;
}
}
Thanks for your help and time.
Raj
|
|
|
|
|
Why are you trying to override this? If you're just using a SortedList , you just use it like the code example I gave. If you do want to extend a class, you only have to override abstract methods, and override other methods and properties as you need to. In this case, though, it's seems like you don't need to.
Besides, when you declare an indexer for a class in C#, you use the following syntax:
public object this[int index]
{
get { return internalList[index]; }
set { internalList[index] = value; }
} Read the .NET Framework SDK for more information, especially since your new. Specifically, see the Visual C# Language[^] topic.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've played around with suspendlayout.
I believe it's there to stop changes to layout being applied before you have done all the changes that you need.
However, i've used the two following pieces of code, and they produce dramaticaly different effects in terms of rendering:
Code one: Low Flicker, Pretty neat solution
<br />
this.SuspendLayout();<br />
this.Size = new Size(newWidth,newHeight);<br />
this.Location = new Point(newXLoc, newYLoc); <br />
this.ResumeLayout(true);
Code two: High Flicker, massive jerking to either side of resize points.
<br />
this.SuspendLayout();<br />
this.Location = new Point(newXLoc, newYLoc);<br />
this.Size = new Size(newWidth,newHeight); <br />
this.ResumeLayout(true);
Any ideas why this is if they are only applied after ResumeLayout is run?
Cata
|
|
|
|
|
Read the documentation for SuspendLayout and ResumeLayout if you're wondering what they do. It pretty much states what you already suspect. If you have the documentation installed locally for VS.NET (and any decent developer should), it's a heck of a lot quicker than waiting for a reply.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know what it does, but I was wondering why it displayed different behavior depending on layout if it was executed at the same time.
All i did was switch the two middle lines around, and it looks hideous.
|
|
|
|
|
I've got a C# application that connects to a database, and does various things with it. My question is this: When designing an application that uses a database, what is the best programming practices to ensure speed and reliability? Should I have just one dataset with many adapters, or multiple datasets and multiple adapters? Will having many adapters cause my form to take longer to load? I'm able to use these things fine, but I don't want an inefficient application in case I am doing something wrong. Thanks..
Also, I notice that if I set the source of a comboBox to a column in a table, that the comboBox takes the liberty of setting the text to the first item in that column. I've tried various things, like setting the comboBox.Text = "", or setting the selectedItem to -1. So far nothing has seemed to work...I want the comboBox text to start out empty...any suggestions?
|
|
|
|
|
The time to initialize a DataAdapter is negligible compared to the time to execute its Fill or Update methods which opens the connection and executes the appropriate commands based on the DiffGram (DataSet which change-tracking information). Set up your DataAdapter s either upon initialization or use a provider pattern that initializes them only when needed (leaving the instances alive for future use).
Also, it's good to use typed DataSet s. Typed columns refer to the columns in your tables directly, where referring to them by index - or worse, by name - requires several lookups. You can create typed DataSet s in VS.NET by adding a new DataSet class to your project (Add->Add New Item) or using xsd.exe. The Solution Explorer can also help if you create a new DataSet class and drag-n-drop tables, views, or stored procs from a database connection to your design surface.
Finally, you really should read about the <cdoe>ComboBox.Text property. For one, it's only effective in some cases depending upon the value assigned to ComboBox.DropDownStyle . If you want to insert an empty element, after setting the DataSource property call Items.Insert(0, ""); or something similar. Take care, however, since this screw up your data binding (by inserting a null/empty column in your tables, which may violate a key constraint).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Doug:
I had the same problem with this in my program as far the the combobox is concerned. What i did was the following after a search.
dataset.Movie.Clear();
oleDbDataAdapter1.Fill(dataset);
if ( dataset.Movie.Count>0)
{
comboBox1.Text=dataset.Movie[0].Title;
}
else
{
comboBox1.Text="Sorry Jack No Data is in the Database!";
comboBox1.Enabled=false;
}
Hope this helps ya
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
I am using multiple projects and I am trying to add project refernece to another project and I get the following error message:
A reference to NDMUI could not be added. An assembly must have a "dll" extension in order to be referenced.
I have these AssemblyIfo.cs file and i tried to sign the assembly, but i didn't write the KeyFile atribute because i can't find the CPS that is installed on my machine. Could this be the problem??? Please help where you can.
|
|
|
|
|