|
Excerpt from MSDN:
Encoding Constructor (Int32) [C#]
Initializes a new instance of the Encoding class.
[C#]
[Serializable]
protected Encoding(
int codePage
);
Parameters
codePage
A code page value that corresponds to the preferred encoding.
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
System.Text.Encoding.Default is for your current system codepage, but if you need others you will have to go the way above.
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Is there a way to read and eventually
store excel files with .net? Possibly
no MSOffice Suite would be installed
on the machine running the program.
I'd like to know a way to read data from
excel spread sheets and access data bases
and to store data in them on a computer
that will not have any of these products
available.
The data will be created with excel and
viewed on a different computers and eventually
modified (very basic modifications).
I need to know this for a windows application
and probably later for ASP .NET application.
Goal is not to replace excel but to create
higly customised program without to use
excel itself.
(what about MS word documents?)
|
|
|
|
|
You can work with Office XP via .NET.
Office XP Primary Interop Assemblies[^]
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Unfortunatly he says this
"Possibly no MSOffice Suite would be installed on the machine running the program." So the interop assemblies won't help.
There is a product out there somewhere which can write excel documents; IIRC it was advertised a lot on ASP-oriented developer sites. I want to say it was by SoftArtisians but I can't remember.
What do you know... ExcelWriter 4.0[^]
James
- out of order -
|
|
|
|
|
Excel writer is only a writer. And on top of that, it's a server license, etc. I wonder who f***ing cares about such things.
The easiest way to read/write Excel spreedsheets is of course ODBC. Or DAO. Choose your weapons.
MSO and stuff is only required when it comes to charts, pivot tables, ...
Back to real work : D-16.
|
|
|
|
|
The problem is so badly explained that you can't be blamed for providing an irrelevant answer. The interop assemblies are only forwarders, and require the stinking Office XP app binaries to do ANYTHING.
Back to real work : D-16.
|
|
|
|
|
Actually, all you need is ADO installed (i.e. the .NET Framework contains the ADO.NET) and you'll need the Microsoft Jet 4.0 installed (download it from the MDAC homepage.
You can use Connection Strings (www.connectionstrings.com) to grab all data from an Excel spreadsheet. This works great if the sheets you'll be reading / writing are in a Table format. If the structure of the spreadsheets are more complicated, you'll need to rely on the Excel object model, which, as you said, may not be installed.
|
|
|
|
|
Both Excel and Word store info as OLE Compound document.
You can write to MS (there is an email specified in MSDN) for the file format specification. As for as I can remember Excel uses something called BIFF (Binary File Format etc..) and there is a BIFF reader sample in msdn. Alternately you can also try for the office resource kit which gives you both the file format as well as soom tools to help you sort out things.
All the best.
<edit>
the above stuff applies to plain old win32, sorry I wasn't thinking of .net.
- Kannan
|
|
|
|
|
Ok, I am designing a custom Control (i.e. ComboBox) in .NET. However, I want to handle a couple Events of the Parent Form so I can handle closing the Drop-Down List appropraitely (I am NOT Inheriting from ComboBox!). I know I can do this somehow by SubClassing, but how do I hook into the Events (I do not want to use a Timer!)?
Can anyone help? Please!?
|
|
|
|
|
It is not really clear here if you are asking about subClassing a control or a form. Each has very different approaches to what you want to do.
So if, for example, you inherited from the textbox control. You inherit all of the base class methods and events. You can (usually) manange your own events by doing:
<br />
private new void Control_Event(parameter, parameter)<br />
{<br />
mycustom event code<br />
}<br />
I say USUALLY because something like modifying the ADD event for a listbox is not possible since that method lives inside the ListItemCollection which is marked as not-inheritable.
Now....if you are actually managing events from ANOTHER control that is on a form that your custom control will live on, that is a different story.
One approach you can take depends on the use, placement, and mangement of the controls be consistant for all users of this form. You create a base form which contains the custom control, the controls you want to capture events for, and any other pretty-pretties such as header data and such.
Code in all of the events you want coded in there such as closing a combo box when the client clicks on a textbox area (as an example). Test out all of your code making sure that the form behaves the way you want it to. Then when the testing is done, change the project type from Windows Application to Class Library and compile it.
Your developers will create reference to that DLL and when they want to create the form, the do an Add Inherited Form... to create a derived class from your form.
THE ONLY CAVIAT that I have found so far is that inherited forms do not create the [STATHREAD] code. This requires the developer to either a) not have this form start a project -or- b) manually add the [STATHREAD] section to the form before compilation.
An inherited form acts exactly like an inherited class --- you can do your own thing but you won't see the base class methods or code. If a developer attempts to override one of the events you had coded, the compiler will stop it letting him/her know that there is a base method already existing. But they can also polymorph it and put in their own code at will.
Hope this is what you were looking for!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Ok, I found the answer to my question. Basically, I added an Event Handler which Hooked intot he Parent Form's LostFocus and GotFocus events.
|
|
|
|
|
Is there way to change the color of the headers in a ListView? Any suggestions, code, links.
Thanks in advance.
|
|
|
|
|
With thanks to Daniel, and others, I have a combo box which lists all my databases, and I am able to get a list of tables with this code:
ComboBox cb = (ComboBox)sender;
m_conn.ChangeDatabase(cb.Items[cb.SelectedIndex].ToString());
SqlDataAdapter dataAdapter = new SqlDataAdapter("select * from INFORMATION_SCHEMA.TABLES", m_conn);
dataAdapter.Fill(m_dsTables);
Now all is good, except that as m_dsTables is bound to my grid, when it updates, it keeps the old values as well as displaying the new. This is not what I want - how can I get the DataGrid to reset itself ? Is it something I've misunderstood about how I am working with the dataSet ? I'm thinking so, but any help would be appreciated, coz I am not sure at this point in time what is going on....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
Is it something I've misunderstood about how I am working with the dataSet ? I'm thinking so, but any help would be appreciated, coz I am not sure at this point in time what is going on....
I think someone asked this earlier and the answer was to un-data-bind it which clears the DataGrid, then you can bind it again and it should then not have the old data-items.
Not sure though, will try it this evening.
[edit]
Just read this 4GysFromRolla.com article and it mentions clearing the database to stop this happening.
[/edit]
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote:
...can you imagine a John Simmons stalker !
|
|
|
|
|
IIRC, Fill doesn't clear out the existing rows in the underlying DataTable.
James
- out of order -
|
|
|
|
|
I'd do a m_dsTables.Clear() before the fill operation.
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Hi,
I would like to create a context menu when a right click on a simple button or any other control. I need this menu with few options to execute other code.
Does any one have any little sample code to do this or maybe some reference?
Thank you in advance,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Hi I search too for this information please Help us.
THX Badgott
|
|
|
|
|
The "Text" property is not showing up for one of my custom controls, although other properties show up. If I make my own "Text" property, the compiler tells me to put the override or new since my parent has the same property. HOw come it does not show up (although many inherited properties show up)? Does it have anything to do with some attribute?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
try this attribute on your custom property.
[Browsable(true)]
|
|
|
|
|
I found about 10 syntax coloring/highlighting articles here on codeproject, but none are for C#. I've been trying to get RichTextBox to do it, but it always ends up being too slow, disrupting the user while the user is typing, if the file is medium sized like 40k. It's not really possible to do with richtextbox in c#, because the interop to do selection is so slow.
Anyone working on such a control or does anyone know of one?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
You can take a peek at how SharpDevelop[^] does it.
James
- out of order -
|
|
|
|
|
i want to creat a dir in system32 dir is it the right path
is there any changes in %systemroot% require for path?
%systemroot%\\system32\\
r00d0034@yahoo.com
|
|
|
|
|
No, that should work. You could also use %windir%\\system32
A good way to check this type of stuff is to type the environment variable in to the Start|Run... box. That will put you right in the specified directory. Or, if you wanted a .NET way to find the System Directory, you could always do System.Environment.GetFolderPath(SpecialFolder.System);
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|