|
Thanks: it works
Ariadne
|
|
|
|
|
can anybody show me how to add checkboxes to DataGrid and how to know the items that is checked.
Rock Throught The Night
|
|
|
|
|
|
I have a class i made that is derived from a label. I was wondering how in the heck do you disable word wrap? I tried this.AutoSize=false; but that doesn't seem to effect anything.
I was looking for something like WordWrap but i don't see anything like. Is there a function i can call to dispable this? Cause what happens is the text on my label is sometimes longer than the label and instead of cutting it off it just makes the label height bigger so it can accomidate the length. Basically word wrapping it.
Thanks for the help
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
As usual, the solution comes down to the underlying Windows common control - the Static Control[^]. You can disable word wrap using the SS_LEFTNOWORDWRAP (0x000c) style. Tie it to a property like so:
public class MyLabel : Label
{
private bool wordWrap = true;
private const int SS_LEFTNOWORDWRAP = 0x000c;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
if (!wordWrap) cp.ClassStyle |= SS_LEFTNOWORDWRAP;
return cp;
}
}
[DefaultValue(true)]
public bool WordWrap
{
get { return wordWrap; }
set
{
if (wordWrap != value)
{
wordWrap = value;
RecreateHandle();
}
}
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I want to add my own functionality (Some Menu Item) to VC6.0 IDE. Can we do that ?? If yes, how to do that? If anybody got some clue, just advise.
Thanks and Regards,
Satya.
Never never never give up.
|
|
|
|
|
SatyaDY wrote:
If anybody got some clue
First CLUE: Post in the correct forum
SatyaDY wrote:
just advise
Advice: Post in the correct forum
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
1. how i will know which version of .net framework that is there in my machine.
2. how i will locate through programming.
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
sreejith ss nair wrote:
1. how i will know which version of .net framework that is there in my machine.
There's no excuse to not know what software is on your computer, unless network administrators are pushing out installations. Never blindly install anything on your machine. This is true for any machine and for any application.
You can figure it out many ways. The easiest is to browse to %WINDIR%\Microsoft.NET\Framework. The sub-directories in there will tell, so long as their full of files (newer frameworks install a few files into older directories, but it's noticably fewer files). v1.0.3705 corresponds to the .NET Framework 1.0. v1.1.4322 corresponds to the .NET Framework 1.1. You can also just open Add/Remove Programs from the Control Panel and look as well.
Programmatically, it's really quite easy. Read about the Environment.Version property in the .NET Framework SDK. The Version.Major and Version.Minor numbers should correspond to the .NET Framework version that you're running under.
Note that the assembly versions don't reflect this. .NET 1.0's assemblies versions are 1.0.3300.0, while the SP2 file versions are 1.0.3300.228. The .NET 1.1 assemblies are version 1.0.5500.0. I don't know why, but that's the facts. I will tell that Microsoft does change the file versions to reflect the service pack changes, but the assembly version remains unchanged so that code targeting that .NET version doesn't need to be recompiled or redirected. File versions are for informational purposes where assembly versions describe both the assembly as well as a type within that assembly. Different versions mean different assemblies or types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
How do I create the IDataSourceLocator (hWnd) for my MSDASC.DataLinks object without first calling the PromptNew() method plus DialogResult.OK ??
I have a program where I want the user to be able to edit a connection string known (loaded) when the program starts. I want to be able to do something like this:
private ADODB._Connection m_AdoDbConn;
// then, create m_AdoDbConn without calling PromptNew() so I can do..
m_AdoDbConn.ConnectionString = sConnStrLoadedFromDisk;
object o = (object) m_AdoDbConn;
MSDASC.DataLinks oDlg = new MSDASC.DataLinksClass();
oDlg.PromptEdit(ref o);
---------------
TIA,
Matt
|
|
|
|
|
All you need is a valid connection string. I created an RCW from the MSDASC typelib and imported the PIA for ADODB (ADODB.dll). My sample code below worked fine (except that I changed the computer name in the ConnectionString ):
using System;
using ADODB;
using MSDASC;
public class EditDSN
{
static void Main()
{
ConnectionClass conn = new ConnectionClass();
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;"
+ "Data Source=MACHINE;Initial Catalog=master";
object o = conn;
DataLinksClass links = new DataLinksClass();
links.PromptEdit(ref o);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath, You are the man! Thank You.
|
|
|
|
|
Does anyone know how to control scrolling programactically, e.g. scroll to the very end of the form?
Thanks!
|
|
|
|
|
P/Invoke SendMessage and send either the WM_HSCROLL (0x0114) or the WM_VSCROLL (0x0115) messages to the control handle (see the Control.Handle property in the .NET Framework SDK).
This has been covered many times here in the C# forum in the past, so I direct you to a previous response and urge you to try searching for answers first by clicking "Search comments" above the message board, or search the articles using the search textbox underneat the CodeProject logo.
See http://www.codeproject.com/script/comments/forums.asp?msg=719589&forumid=1649#xx719589xx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am developing a NotifyIcon app with C#. I want to show the context menu
when user left-clicks on the icon, the same as he/she right-clicks on it. In
that event handler, myNotifyIcon_Click(), I call
myNotifyIcon.ContextMenu.Show method. But I am not sure what these two
parameters I should feed.
Thanks in advance.
David
|
|
|
|
|
There are many ways of doing this. The NotifyIcon component encapsulates the Shell_NotifyIcon functions and context menu-related functions like TrackPopupMenuEx . While you could simply P/Invoke the latter API as well as a few others, the easiest way would be to use Reflection to invoke the method that already does all this for you:
MethodInfo method = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null) method.Invoke(notifyIcon1, null); If you want to know how that method works, use the IL Disassembler (ildasm.exe) that ships with the .NET Framework SDK if you know how to read Intermediate Language (IL), or a good decompiler like .NET Reflector[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please read the code snippets below
snippet 1: Drawing rectangle using Device Context
-------------------------------------------------------------[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool Rectangle(
IntPtr hdc,
int ulCornerX, int ulCornerY,
int lrCornerX, int lrCornerY);
public void GetHdcForGDI(PaintEventArgs e)
{
// Create pen.
Pen redPen = new Pen(Color.Red, 1);
// Draw rectangle with GDI+.
e.Graphics.DrawRectangle(redPen, 10, 10, 100, 50);
// Get handle to device context.
IntPtr hdc = new IntPtr();
hdc = e.Graphics.GetHdc();
// Draw rectangle with GDI using default pen.
Rectangle(hdc, 10, 70, 110, 120);
// Release handle to device context.
e.Graphics.ReleaseHdc(hdc);
}
-------------------------------------------------------------
snippet 2: Drawing rectangle using PrintPageEvntArgs
-------------------------------------------------------------
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Pen redPen = new Pen(Color.Red, 1);
e.Graphics.DrawRectangle(redPen, 100, 100, 100, 100);
}
-------------------------------------------------------------
Please explain what is difference between drawing rectangle using Device Context and PrintPageEvntArgs in terms of the concept and merits
regards
|
|
|
|
|
A device context can be practically any output device, from a monitor to a printer to a virtual screen buffer. You actually have to set up a device context (or get it from an existing source) and translate all the units if necessary. It also requires marshaling to a P/Invoke'd function.
Painting to a printer using the .NET FCL printing capabilities handle everything for you and should be used. Besides, look at what you had to do to draw a simple rectangle using the HDC compared to the Graphics object (which is actually a GDI+ object, where an HDC is used most often for GDI).
If you want to learn more, read about the HDC and GDI functions in the Platform SDK and compare that with the graphics information in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've noticed that some programs have nice smooth icons with lots of colors, whereas others are the regular type with jaggie edges and up to 256 colors.
How is it possible to create such icons and add them to the application in VS.net & C#?
|
|
|
|
|
You need a program that can do that. Typically, these icons are created in a decent graphics program like Adobe Photoshop using alpha channels (not just anti-aliasing, which requires a background color to blend with). You can then use a program to save the images (some can even read PSD files, but you typically save the images, or frames, in a format that supports alpha channels like PNG) as icons, like IconWorkshop, from Axialis[^], which I like and use.
Then, you simply use these in your .NET applications. You can, for instance, create an ImageList with 32-bit colors (to support the alpha channel). There is a problem, though: the ImageList contains a bug where the alpha channel is typically lost. You can help this by placing a .manifest file in the same directory as your executable (using the executable name + .manifest). This binds the GDI+ ImageList to Windows Common Controls 6, which features alpha channels. See my article, Windows XP Visual Styles for Windows Forms[^] for a brief overview of the .manifest file. Other articles here on CodeProject discuss other ways to get around this bug.
You can also load these images or icons yourself using other classes in the System.Drawing namepsace, such as the Bitmap class. Read the .NET Framework SDK documentation for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
There is a problem, though: the ImageList contains a bug where the alpha channel is typically lost. You can help this by placing a .manifest file in the same directory as your executable (using the executable name + .manifest). This binds the GDI+ ImageList to Windows Common Controls 6, which features alpha channels.
The problem then is that the background never gets invalidated, and hence u end with 'halos'. Best just to draw it yourself.
Btw Heath, do you know whether all of these Image related bugs in NET have been fixed in version 2? Especially the ImageList bug, where the implementor never checks the bounds or an image inserted?
top secret xacc-ide 0.0.1
|
|
|
|
|
I haven't actually had a lot of chance to play around with it. I've just been too busy here at work and frankly don't work on my computer much at home anymore (I do it enough hours here at work).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
I've just been too busy here at work and frankly don't work on my computer much at home anymore (I do it enough hours here at work).
I wouldnt have said so!
top secret xacc-ide 0.0.1
|
|
|
|
|
I still accomplish a hell of a lot and am expected to do just about everything, so it needs to get done (though I delegate quite a bit of stuff to my employees. Cummulatively, I probably only spend about 45-60 minutes / 11-13 hour work day, unless there's a crunch for something. With all those hours in a day and what I have to go through, I think I'm entitled to a little personal time.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What about such icons as the application icon?
I notice some programs like AIM and VS use the newer looking icons.
However there doesnt seem to be a way to set something like a PNG image as the application icon.
Is it possible to to that for the app. icon in VS?
Thanks!
|
|
|
|