|
How about aligning the text that's shown in the ListViewItems to right or center ?
Can that be done !?!
|
|
|
|
|
While aligning text in the header is easy (ColumnHeader.TextAlign ), you'll once against have to override WndProc to do this. Once you do that, handle WM_CUSTOMDRAW, and redefine a few PSDK structs (like LVITEM), this is actually pretty easy.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
[edit]Forget what's below, this is not intended to do a column header wrapping, but only to auto-fit the width of header columns[/edit]
Instead of creating columns by passing a positive integer, pass -1 to it.
Namely, instead of writing :
listView1.Columns.Add("Very very large column name",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Columns.Add("col2",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Items.Add( new ListViewItem("My Item1"));
write :
listView1.Columns.Add("Very very large column name",-1,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Columns.Add("col2",50,System.Windows.Forms.HorizontalAlignment.Left);
listView1.Items.Add( new ListViewItem("My Item1"));
And see how column 1 is nicely wrapped to adapt the content in columns.
PS : for your info, -1 is constant LVSCW_AUTOSIZE = -1 declared in commctrl.h
RSS feed
|
|
|
|
|
Hi,
My Question Is: with regards to XML in a C# context.
For the record, I'm using VS 2002, running Win2000 dayly updated, cel400mhz,192ram,dotNET1.1
The Premices:
Put simply, I am trying to use XML as a relationnal database for an application.
I figured an XML schema, an XML file, and some code to plug it in and that was it.
The application is to store contacts information and more types of info
as we upgrade it. So what makes sense here is to have an XML file for each type of info.
The user needs to be able to do the usual, such as view, add, modify, delete entries.
The XML files should reside in the main application folder. Now, this is part of what I tried:
-please bare in mind I'm kinda new with xml...
The Faulty Code:
string item;<br />
XmlDocument myDoc = new XmlDocument();<br />
<br />
myDoc.Load(Application.StartupPath + "\\Contact.xml");<br />
<br />
XmlNode myNode = myDoc.FirstChild;<br />
item = myNode.FirstChild.InnerText.ToString();<br />
txtFirstName.Text = item;
The Error Message:
An unhandled exception of type 'System.NullReferenceException'
occurred in Orchus_temp.exe Additional information: Object reference
not set to an instance of an object.
The Question Redux:
" How do I add, modify, view and delete data that is stored in an XML file and rendered in a C# application? "
I propose to write an article about the resolution of theses issues, since a
lot of people have to resolve these kind of problems, I believe.
So feel free to respond extensively as this will be the substace of my first article!
Thanks!
Antoine Dubuc
Montreal, Canada
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
You can try generate a TypedDataset from the schema
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
myDoc.FirstChild; is the problem.
this is not a safe way to read an XML file - the first child could be a processing instruction...
you are better of using SelectSingleNode(xpath);
where xpath is the thing you want - in you case I'm guessing its "/contact/firstname" depending on you xml file structure...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Good.
Xpath is something new to me. I'll check that out and try it.
thank!
Antoine
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
Hi Phillip,
Ok. So I am trying to display the firstname of the first contact in the Contact.xml file...
XmlDocument myDoc = new XmlDocument();<br />
myDoc.Load(Application.StartupPath + "\\Contact.xml");<br />
txtfirstname.Text = myDoc.SelectSingleNode("//Contact[1]//firstname").Value;
What am I missing? I am trying to find a good XPath resources, but its hard. MSDN doen't do it for me up to now.
thanks
Antoine
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
Hello Guru,
How to embed an icon to your main EXE file? So the icon shows up in windows explorers. I would appreciate very much any of your tips.
Thanks
Have fun with C#
Khang Nguyen
|
|
|
|
|
Just replace the app.ico file with your icon and it will build with your icon.
|
|
|
|
|
Wow! You're great, Daniel! Thank you so much.
Khang
|
|
|
|
|
I have searched throughout code project, GotDotNet, the SDK, and the Internet without any resolution!!!
When I write an entry to the Eventlog, I get the following message appended to my message:
The description for Event ID ( 0 ) in Source ( Navigator ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer.
So what do I need to do to establish a message DLL file and have my Event ID's defined so that the Event logging works properly? Does anyone know?
Thanks,
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I would like to make the dropdown for a combobox display the last selected item in the middle of the listing area rather than at the top. Everything I've tried so far (Click event, DropDown event) only seems to affect the control before the dropdown list is displayed. Even tried subclassing to override the OnDropDown, but again everything occurred before the list was displayed.
Thanx for any help...
>>>-----> MikeO
|
|
|
|
|
Hi!
I'm created Windows service project(C#) and now I want to debug code.
In MSDN i read instructions, but I have a PROBLEM in first step, with installing my service.
I was write in cmd line "InstallUtil.exe myservice.exe" and I get a result in log file (attached). Looks ok!????
But I don't see a service name in Server Explorer (or in Admin->Services) list, so I could not start the service.
Could you help me and write me what i doing wrong.
TNX 1000 times.
Hambi
David Pavlovič
david.pavlovic@adacta.si
|
|
|
|
|
Did you add both the ServiceInstaller and ServiceProcessInstaller components to your project and "configure" them accordingly? If you just run InstallUtil.exe on your service without those things, it won't actually do anything.
Be sure to check the documentation for those two classes, as there's several things you must understand to make it work, like using the same service name (not the display name) for both classes, etc.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Please check following codes, it dosen'g work properly, the title bar is still empty.
( the method PanitNonClientArea(Graphics, RectangleF) can work properly. )
<br />
protected override void WndProc(ref Message m)<br />
{<br />
Graphics g;<br />
RectangleF rectf;<br />
<br />
Point pt;<br />
<br />
switch (m.Msg)<br />
{<br />
case WMConsts.WM_NCPAINT :<br />
IntPtr hrgn = m.WParam;<br />
if ( hrgn != (IntPtr)1 )<br />
{<br />
Region rgn = Region.FromHrgn(hrgn);<br />
g = CreateGraphics();<br />
rectf = rgn.GetBounds(g);<br />
PaintNonClientArea(g, rectf);<br />
}<br />
else<br />
{<br />
g = CreateGraphics();<br />
rectf = new RectangleF(0,-23, Width, 23);<br />
PaintNonClientArea(g, rectf);<br />
g.Dispose();<br />
}<br />
<br />
break;<br />
<br />
default :<br />
base.WndProc (ref m);<br />
break;<br />
}<br />
}<br />
|
|
|
|
|
I want to create a menu control on top of all windows and desktop as parent.so that I can make it available to all applications..Is it possible?
VikramS
|
|
|
|
|
You mean a menu-like equivalent of the Taskbar? Yes, it's possible. If you plan to do this in C#, you're going to be redefine a hell of a lot of interfaces and structs. You best stick to C++ because this requires a lot of COM.
For starters, see the Platform SDK docs for the SHAppBarMessage function, or search for said function in google. There are lots of examples, though mostly in VB and Delphi, but it shouldn't be hard for you to understand the concepts.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Good find!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Im writing a toolbar for internet explorer . I am usijng COM . I need to access the current document in the browser . How do i do this . Ie what are the classes i can use . The code for this is to be embedded in the toolbar and the functions in the toolbar code should be able to perform some actions on the document in the browser . Also importantly i need to get the selected /highlited section in the document . Are there direct classes supporting this operation .
Srikar Y
NITK Surathkal
|
|
|
|
|
First, wrong forum.
Second, when writing COM clients, there's really no such things as classes that you can access. Everything is done through interfaces. If you're writing a COM server, you of course use classes but they implement the interface through which clients access the classes. This is one of the fundamentals of COM.
Finally, when the host (Internet Explorer) calls IObjectWithSite::SetSite(IUnknown*) , you QI (QueryInterface) for the IWebBrowser2 interface. That's your web browser. Later, call IWebBrowser2::get_Document(IDispatch**) and QI the IDispatch for IHTMLDocument2 (or a newer interface, depending on your browser requirements).
Next time, though, there is a forum for ATL and COM. This would be a more suitable place. If you are using C# to do this, instead of QI'ing for an interface, you simply do a type-cast. The CLR treats this the same.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
How can I draw zigzag red lines under some words in a RichTextBox or any other textual environment? (Just like what is done in spell checkers)
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
I create a MDI contain form, add a MainMenu, a ImageList, a ToolBar, and the ToolBar relate the ImageList.
When I use the function Application.EnableVisualStyles() to enable xp style, the toolbar icons are disappeared. But when I use instead of a manifest file, the toolbar icons display correct.
Is this a bug with .net framwork 1.1?
(I used VS.net2003 simplified chinese version)
=== Game is power! ===
|
|
|
|