|
Thank you for the help, I got it to work with the code you wrote. Thanks richard_d (on both sites) and joan_fl!!!
|
|
|
|
|
How do you scroll a window in .net? I want to make a RichTextBox scroll to a certain position, without using ScrollToCaret(). I tried using the user32 SetScrollPosition, but that just moves the scroll bar itself. In other words, the scrollbar moves, but the window doesn't scroll.
Is there a ClippingRect object in C#? I can't find it in the Control class..
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Hi you can make one! But just for the RichTextBox...
private Size contentsize = Size.Empty;
protected Size ContentSize
{
get
{
return contentsize;
}
}
protected override void OnContentsResized ( ContentsResizedEventArgs e )
{
contentsize = e.NewRectangle.Size;
base.OnContentsResized(e);
}
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
And the other part...
[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected Point ScrollPosition
{
get
{
Point pt = Point.Empty;
User32.SendMessage(base.Handle, Constants.EM_GETSCROLLPOS, 0, ref pt);
return pt;
}
set
{
User32.SendMessage(base.Handle, Constants.EM_SETSCROLLPOS, 0, ref value);
}
}
Obviously you just need to define a User32.SendMessage like:
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, ref Point lParam);
CHeers
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
|
How do you associate a file type (extension) with your application (in .NET if possible)?
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
|
|
|
|
|
I think this can be done through registry
- Kannan
|
|
|
|
|
Look in the deployment projects... there's a real easy way to add it. Not 100% sure how to implement something such as an "OPEN" when the file is 2x-clicked.
-AC
MCDBA
http://www.aconnell.com
|
|
|
|
|
|
Have somebody seen CodePageEncoding class in the .NET documentation, or in the library? Where it is, or has it been thrown away from the final release?
I really wander whether somebody is using it. This class is referenced in Dr. GUI .NET article #5 (from May 31, 2002 - quite fresh issue). According this article, the CodePageEncoding should be in System.Text namespaces.
However, I'm not able to find it in my libraries. I cannot find it even in the documentation accompanied with VS.NET, as if this class never existed...
Vasek
VB6, C#, MS DNA, MS .NET software developer
|
|
|
|
|
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 !
|
|
|
|