|
I've solved my problem, so I'll share with you
In the contructor I set the StartPage property to a huge number (say, 1 billion). Then I install the StartPageChanged event handler. After the print preview is generated, I get that event, with StartPage set to the last. I save the page number, and then restore it to the first page.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Does anyone know what needs to be done to programmatically check or uncheck a checkbox in Excel using C# (or even VB.Net)? I already have the code to open an excel document, change cells, update links, save, and close, but the checkboxes are killin me.
I have tried using the Worksheet.CheckBoxes(object Index) method to try and retrieve a CheckBox object, but it doesn't work. It returns an obscure COM error. I tried it by using both the checkbox name and a number for the Index parameter. When attempting to generate a macro in excel to change the value of the checkbox, no code is generated when performing actions to the object. I don't want to have the checkbox link to a cell, and change the cell to control the checkbox -- that is lame. But if no one can find a solution, I may have to do it that way.
-----------------------
I pity the foo.
-Mr. T
|
|
|
|
|
I just cant' get how to draw strings with "proper" letter spacing,
especially when they're bold. Some letters in specific combinations
when being drawn next to each other appear slured (without even a pixel gap).
The font I'm using is the default MS Sans Serif 8,25pt
Here's a link to a sample screenshot:
>> link
The left one is drawn using the Graphics.DrawString method and the right one is
a screenshot from a ListView. Why is that difference?
How to achieve this?
|
|
|
|
|
iliyang wrote:
How to achieve this?
May be you must change the StringFormat class ?
|
|
|
|
|
Well, turns out that it is a global issue and there's no way
(at least that I know) that can fix this. Thе string that I
drew was something like "bla bla the_messed_part" (1) and the string
in the listview was "the_messed_part" (2). And when I tried to
draw the string (2) or let the listview draw the string (1)
both work the same way. So I guess the solution is to choose
a different font like Tahoma, for example, which looks like MS Sans Serif.
Of course, this is not a very good solution, 'cause this way I'm
fixing the font and if the user has a totally different system font
set, it'll be pretty ugly...
|
|
|
|
|
I have successfully written a C++ DLL and can pass integer types from C++ to C# using the DllImport method. However I can not figure out how to pass a string (byte array or any other type) from my C++ dll to C#.
The C++ DLL side compiles without error and creates a DLL file. The C# side produces compiler errors no matter how I try to pass the string (have tried everything I can think of). Since Interoperation is a
"virtue" in Visual Studio I am sure that there is a simple solution but it eludes me. Here are the relevant code sections:
In C++ DLL header (.h)
extern "C" __declspec(dllexport) int addfive(int x);
extern "C" __declspec(dllexport) char* putFolderList();
In C++ DLL source (.cpp)
int addfive(int i) { return i+5 ;}
char* putFolderList(){ return "my string" ;}
In C#:
using System.Runtime.InteropServices;
[DllImport("DLLBuildTest.dll")]
static extern int addfive(int x); // VALID
static extern char* putFolderList(); // NOT Valid
errors (2) and warnings (1) from C# compilation:
#1 - warning CS0626: Method, operator, or accessor 'DLLCaller.Form1.putFolderList()' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation
@2 - error CS0214: Pointers may only be used in an unsafe context
#3 - error CS0029: Cannot implicitly convert type 'char*' to 'string'
My question is: What is a valid method for passing a string from a C++ DLL to a C# program?
Paul Largent
|
|
|
|
|
Doesn't
static extern string putFolderList();
help?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I've created a TreeView which lists items from active directory. With the help of another Code Project user, I've created a context menu which is specific to the type of object right-clicked-on by the user.
The problem is that when I select the menu option, the 'sender' holds a reference to the MenuItem, not the TreeNode clicked-on in the first place.
How can I get a reference to the original TreeNode that the user right-clicked on?
I've thought of one way but it seems a bit of a botch: to create a TaggedMenuItem class inherited from MenuItem which has a 'Tag' like Controls have and to use the MouseUp event and populate the Tag of EVERY TaggedMenuItem on the context menu with a reference to the TreeNode as I create the context menu. Then, I can get back to it from the menu item click event handler. Like I said, this sounds a bit crap.
Is there a better way?
|
|
|
|
|
You can subscribe to the MouseDown event and figure out which node was right-clicked on with the help of the mouse coordinates.
Point point = new Point(e.X, e.Y);
TreeNode node = feedTreeView.GetNodeAt(point);
You can then store node in a class level member variable, which you can then access from anywhere within the class.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks for your suggestion. I'm new to OO and I think I was just over-complicating things!
Regards
SH
|
|
|
|
|
How does a HashTable stores data ? it stores inside itself or a HashTable stores only the adress of the object ?
Thanks
|
|
|
|
|
If you store reference types, it stores only references (adresses). If you store value types, I belive it stores values (copies).
David
"Stay Kul And Happy" I.A.
|
|
|
|
|
Only the reference are stored. Not just Hashtable, but any collection stores only references to the objects and not the objects themselves. For value types, the value is boxed and a reference to the boxed instance is stored.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello! I've got a problem.
I've created a class who herits from Hashtable. I've also created a UIEditor to edit the values at design time. But when i do that, there is nothing writed in the InitializeComponent method. My class is however marked as Serializable...
Thanks for your help
|
|
|
|
|
I have a panel with AutoScroll property set to true. the panel contains a picturebox, whose height and width r decided at runtime. Panel's height and width r fixed. When i drag mouse over the picturebox i need the panel to scroll up down right left if the size of the picturebox is greater then the panel. How do i do it?
Thanks in advance
Nitin
|
|
|
|
|
Not bug free, but it gives you an idea
Private _mouseDown As Boolean<br />
Private _lastY As Integer<br />
<br />
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown<br />
_mouseDown = True<br />
_lastY = e.Y<br />
End Sub<br />
<br />
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove<br />
If _mouseDown Then<br />
Dim y As Integer<br />
If e.Y > _lastY Then<br />
y = e.Y - _lastY<br />
Panel1.AutoScrollPosition = New Point(Panel1.AutoScrollPosition.X, y)<br />
ElseIf e.Y < _lastY Then<br />
y = _lastY - e.Y<br />
Panel1.AutoScrollPosition = New Point(Panel1.AutoScrollPosition.X, y)<br />
End If<br />
End If<br />
End Sub<br />
<br />
Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp<br />
_mouseDown = False<br />
End Sub
|
|
|
|
|
Hi,
I need help!
I need to move print job from printer A to Printer B..
my problem is:
I have print's line job and I need to move this to other printers...
How to do it in C#?
please, somebody to know and it will be able to help me...
thank you
|
|
|
|
|
I certainly hope that all of your printers are the same, or at least can use the same printer driver.
You can't move a job from one printer to another. But, you can setup printer pooling so more than one printer can pull jobs from the same queue.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Anyone is using XtraReports from DevExpress.com[^]?
Seems like a great piece of software and the price is right. Comments, opinions?
Thanks!
|
|
|
|
|
I want to make may order with each column has a color by datagrid. But I don't know how to do this. Please help me. Thanks.
|
|
|
|
|
Two things i would like to ask.
1. I would like to do something if the user cliks the x at the topright corner (thus closing the form). How can i get in contact with this click event?
2. What is the general closing event of a form?
I am pretty new, so please give clean anserws that even i can understand
R
Johan
|
|
|
|
|
Add an event handler for the closing event to the form. The easiest way is this (using Visual Studio): go to the View Designer of your form, activate the tab properties and click the Events-button. Look for the "Closing" event in the list and double-click on it. An event handler will be created for you.
When the X in the title bar is clicked, this event handler will be called. It allows you to do some clean-up or even to prevent the form from closing (in contrast to the "Close" event).
|
|
|
|
|
Look at the Form.Closing event. Technically, your event handler for the closing event should only deal with closing stuff and should be "agnostic" as to why or how the form was closed.
|
|
|
|
|
|
Hello everyone,
I was wondering how can I incorporate a classic winhelp file I made into my c# aplication
thx
|
|
|
|