|
No property like this is available, but if you extend NumericUpDown you can simply override UpdateEditText . If Hexidecimal is set, be sure to call the base.UpdateEditText unless you want to handle this yourself. Also, when formatting the number, don't forget to take the ThousandsSeparate into account.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank Heath...that's kind of what I thought. I figured I'd have to inherit/extend it to make it work. I just wanted to make sure there wasn't a property for it that I missed before I went through all the trouble.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
I take it that you looked at the class documentation for the NumericUpDown class, right? Deriving from your sig, "there are 10 types of people in this world...those that read the documentation and those that do not." (Unfortunately, most of the posters here fall in the latter category.)
Typically, you can learn everything you need to know from the docs (add that to experience and reading articles on MSDN, CodeProject, et. al.). If some member overrides a base member of defined new and you find the documentation a little lacking on details, use ildasm.exe - the IL disassembler that comes with the .NET Framework SDK - to view the IL for the implementation in that assembly, or use a good decompiler like .NET Reflector[^] (though its decompiler rarely incorrect / incomplete). You can learn a heck of a lot that way - perhaps even pick up a few pointers from the developers at Microsoft who wrote the base class libraries.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes, I did read the documentation, the problem is that Microsoft documentation isn't always as solid as it could be. Once you've "done it", then you see in retrospect how to "do it", but that doesn't mean the documentation just explains every nuance. Far from it usually. That was why I said up front that I knew it was possible if I inherited the class, but wanted to make sure there wasn't a proprety or something like that I was missing.
I'll keep that in mind about the ildasm.exe....I remember you showing me that on the COM DLL problem I had last week.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
<br />
typedef struct<br />
{<br />
char *item[100];<br />
int top;<br />
}strstk, *strstkptr;<br />
<br />
char *chartostr(char);<br />
char *process(strstkptr);<br />
char *pop(strstkptr);<br />
void push(strstkptr, char *);<br />
<br />
int main()<br />
{<br />
strstkptr pS=(strstkptr)malloc(sizeof(strstk));<br />
char *p;<br />
char buf[100];<br />
char *pV;<br />
<br />
while(scanf("%s", buf) !=EOF){<br />
switch(buf[0]){<br />
case '(':<br />
case '+':<br />
case '*':<br />
p=chartostr(buf[0]);<br />
push(pS, p);<br />
break;<br />
case ')':<br />
pV=process(pS);<br />
if(pS->top==0)<br />
printf("%s ", pV);<br />
else<br />
p=malloc(100);<br />
sprintf(p,"%d", pV);<br />
push(pS, pV);<br />
break;<br />
default:<br />
break;<br />
}<br />
}<br />
<br />
}<br />
<br />
char *pop(strstkptr pS)<br />
{<br />
return pS->item[--pS->top];<br />
}<br />
<br />
void push(strstkptr pS, char *pV)<br />
{<br />
pS->item[pS->top++]=pV;<br />
}<br />
<br />
char *process(strstkptr pS)<br />
{<br />
char *p, *py, *px;<br />
<br />
while((p=pop(pS)) != "("){<br />
if(p="*"){<br />
py=pop(pS);<br />
px=pop(pS);<br />
<br />
}<br />
else<br />
py=pop(pS);<br />
px=pop(pS);<br />
<br />
<br />
<br />
} <br />
}<br />
<br />
char *chartostr(char ch)<br />
{<br />
char *p=malloc(2);<br />
p[0]=ch;<br />
p[1]=0;<br />
return p;<br />
}<br />
I don't know know how I'm supposed to to add or multiply from my stack can anybody help
|
|
|
|
|
C# discussions
Methinks you're not going to get much help here. Try here[^]
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
Hi,
I would like to convert a string of numbers to an integer. I know in C it used to be atoi() but I don't know the equivalent in C# if it exists.
Thanks,
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
you can use the following statement:
int num = int.Parse(yourStringofNumbers, NumberStyles.Integer)
but declare:
using System.Globalization
|
|
|
|
|
|
Thanks! I'll give it a try.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hello everyone,
I have few crystal reports in a project. I need to combine all the reports in one pdf. I can print each report in one pdf file but need to combine all of them in one. Any help would be highly appreciated
Thanks in advance
Ali
|
|
|
|
|
Hi, I looking for :
1/ blinking a Row of ListView;
2/ Show the last row inserted in the ListView when inserted a rnew row.
Best Regards
youssef
|
|
|
|
|
A simple way of flashing a row would be to use a timer (that disables itself after a number of iterations) that toggles the BackColor and FrontColor of the ListViewItem . You could make this consistent with windows by using the appropriate members of the SystemColors class (like Active* and Inactive* colors).
When you say "last row", do you mean the one that was just inserted? If you insert, you'll already know the index because you must specify one in order to insert it. If you add, just get the ListView.Items.Count - 1 . Take that index and assign that to ListView.SelectedIndices to new int[] {index} . You could also keep a reference to the last ListViewItem and set ListViewItem.Selected to true .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible to write my own outlook, but only interface (UI) wise? In other words, does Outlook provide access to it's internals (database, code to send recieve email, account information, etc.)?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
I don't think you want to go there. Outlook does a hell of a lot more than you could possibly imagine.
Outlook does expose its object model, though, providing you programmatic access to send emails, enumerate folders and items, and more. I've used this years ago in a couple different scheduling-type applications.
You can find more about the Outlook object model - along with simple examples - at Office Solutions Development[^], under which you'll find topics on development and articles outlining different solutions.
If you're using Office 2003 Professional (including Enterprise Professional, which is only available with volume purchase orders), be sure to install the Office primary interop assemblies (called something like ".NET Framework Programming Support" or something). If you have Office XP (and they should work in part from '95 up), you can download the PIAs and view information on them at http://msdn.microsoft.com/library/en-us/dnoxpta/html/odc_oxppias.asp[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You are a wealth of information, knock on wood!
Heath Stewart wrote:
be sure to install the Office primary interop assemblies
I did. How can I use them? Should they be added to that folder where the mshtml interop assembly is?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Just run the batch script in the PIA folder if you haven't already. This installs them into the Global Assembly Cache (GAC), which makes them available to all .NET applications without having duplicate assemblies in your application folder. For that matter, the Microsoft.mshtml.dll assembly should be in the the GAC as well if you installed VS.NET. The GAC is a far better place to put assemblies that multiple applications could use because it fosters assembly versioning and is non-specific to any one application. You only need to add a reference to these assemblies in VS.NET for your project, then.
IIRC, the Office XP PIAs do not install a registry key that VS.NET uses to find assemblies in folders (the references dialog does not scan the GAC). To do this, open the registry editor (regedit.exe), go to HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders and add a new key with the default value set to the folder in which your PIAs are located. See the other keys there for examples. Restart VS.NET and when you open the Add Reference dialog, you'll them listed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I must be exceptionally dense today. I have a class derived from ListView and I am trying to handle the notification event when the user resizes a column in the header. I tried to capture it in WndProc as follows:
protected override void WndProc(ref Message m)
{
NMHEADER header;
if(m.Msg == 0x004E)
{
header = (NMHEADER) Marshal.PtrToStructure(m.LParam, typeof(NMHEADER));
int code = (int)header.hdr.code;
if(code == -308)
{
}
}
base.WndProc(ref m);
}
What am I doing wrong?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Which line is failing exactly? Is the first conditional block being entered? Is the NMHDR.code not what you expect?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry, I guess I should have been more specific...I put a break in the inner if test like this
<br />
if(code == -308) <br />
{<br />
int i = 0;
}
It never got there, turns out I have two problems...I couldn't trap any header notification message. One problem was that I needed to call the base class WndProc first like this.
<br />
.<br />
.<br />
.<br />
base.WndProc(ref m);<br />
header = (NMHEADER) Marshal.PtrToStructure(m.LParam, typeof(NMHEADER));<br />
.<br />
.<br />
.
Now I can catch every header notification message except the one I want: HDN_TRACK.
I catch the HDN_BEGINTRACK and HDN_ENDTRACK just fine...I'm thinking there is some kind of bug
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
That's odd. I've handled a lot of ListView messages in a couple different classes and have called base.WndProc last in most cases. Even many of the controls in System.Windows.Forms do that. This gives you a chance to handle messages before the base class does, which may void anything you want to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've built a custom control that displays some objects as text (each text entry is NOT a System.Windows.Forms.Control).
So, after the OnPaint override is called, my control might look like this:
------------
| someText |
| hello |
| blah |
------------
All is well. However, when I write text past the client area of the control, like so:
------------
| someText |
| hello |
| blah |
------------
more text
even more
The last two lines of text that I've drawn are obviously not visible. So, in order to see the last 2 lines of text I've drawn on my control, I need to put in a scrollbar. Using a scrollbar, I can get the last two lines of text to display...however, only if I repaint the whole control, which means that every time I scroll, I need to repaint the control (which results in "flashing").
So, is there a better way to do this? I guess my real question is, what is the normal way to implement custom scrolling?
The graveyards are filled with indispensible men.
|
|
|
|
|
You could just inherit from ScrollableControl , otherwise you're going to have to read-up on the Windows Common Controls[^], primarily the Scroll[^] control. This start getting into the need for Window Handles (the Handle property of a control), the need to override WndProc and more. So, if you don't want to derive from ScrollableControl and override the necessary behavior, you're going to have to learn about Windows programming, messages, and the Common Controls.
BTW, most controls in System.Windows.Forms encapsulate their respective common controls, like the TextBox encapsulates the Edit control. Some controls encapsulate functionality of several common controls. These are complete .NET native solutions like with Java AWT and Swing (which provides a more consistent interface with the window manager, ex. Windows).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I would love to be able to just inherit my control from ScrollableControl and let Windows deal with it. However, since the objects I'm drawing on my control are not System.Windows.Forms.Controls (indeed, I'm just drawing text, not adding controls), the scrollbars never show up, even if I turn on .AutoScroll property. It seems ScrollableControl is used only for a control in which you have actual controls being added to your control...unfortunately I only have text. So, please correct me if I'm wrong, but I don't think ScrollableControl will work in this particular situation unless I'm overlooking something.
I am familiar with Windows programming and the message pump (I've done MFC and ATL development in the past), I was just hoping for an easy solution to the problem. I'll look into the double buffering, though, before jumping into the WinProc override.
As always Heath, thanks for the informative reply.
The graveyards are filled with indispensible men.
|
|
|
|
|
By inheritting from ScrollableControl , you at least get some of the functionality you need, but by no means all of it.
Also, double-buffering is not an alternative to overriding WndProc . Control.SetStyle is something you'd call in your constructor or some other initialization code to enable the three styles that cause .NET to call your painting routines in a separate thread to paint in the back buffer, then to paint that on the screen.
Overriding WndProc is necessary to implement the scrolling. These two things have nothing to do with each other (although you could enabled double-buffering in WndProc yourself, but then you have to handle the back and screen buffers yourself - I'd recommend the latter method).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|