|
I haven't personally found (or really needed) a good printing resource for Win32. However, my impression is that it is primarily generic Win32 GDI calls, with a different dpi and size. So, a reasonable way to test your code would be to separate the code that does actual drawing into a separate function, then send that function any DC handle. When trying it out, you can draw straight to the screen. Once that works, you can draw to the printer DC.
SetTextColor() is what my memory tells me about changing the text color.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Is there any way to add the checkbox control for each subitem in the ListView? thanks in advance for any help.
|
|
|
|
|
You'd have to owner draw the list. Search CodeProject for examples. This will require overriding WndProc and handling notification messages, so experience with Win32 programming will be helpful. There are also third-party controls that offer this behavior out of the box.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've searched the web, and was not able to find any example code. The only one example code in the CodeProject website was way too complicated for my need.
Are you suggesting inherit the ListView & add the checkbox control. I did that, but not sure how to display the control when a new item is added for a subitem (for example, I need a checkbox control display for subitem 2 & 6). I would think it would be the same as adding a image to the specific column, and when click event occurs, switch to another image depending on if the checkbox is checked or not.
thanks in advance.
|
|
|
|
|
You can't simply add the CheckBox control to a sub-item. A sub-item is not a valid windows control and can't be parent to another control. The solution is complicated. If you can't do it, then you should get a third-party control like those from http://www.devexpress.com[^] or http://www.infragistics.com[^].
The .NET controls in Windows Forms encapsulate the Windows Common Controls, which are native controls for Win32. If the functionality you need is not exposed from the .NET controls, you have to go back to the basics of Win32 control programming and handle notification messages and send messages, use Windows styles, and more. That's just the way it is.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
katetsai wrote:
Are you suggesting inherit the ListView & add the checkbox control.
No, he is talking more about using a Panel, or creating a UserControl. Then, do all the drawing and mouse checking for yourself by handling the painting routines, and dealing with MouseDown, MouseUp, MouseMove, etc.
There are many ways to deal with this, it would be an immense help to you if you understood the basics of creating a custom control. So, have a look here: http://www.codeproject.com/cs/miscctrl/cutebutton.asp[^]
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Actually, I'm talking about extending the ListView , overriding WndProc , P/Invoking a few native APIs like SendMessage , declaring necessary consts and structs, and handling notification messages and sending windows messages as necessary like you would in Win32 programming. I've done it to provide sorted column background colors and sorting arrows on column headers. There are several articles on that here on CodeProject as well (though if you have decent Win32 programming experience it's not hard to figure out since it's what you had to do to extend anything anyway).
For instance, you could handle the NM_CUSTOMDRAW to paint to shift the text and draw the check box (for which you can use ControlPaint.DrawCheckBox if you create a Graphics object from the necessary handles). It's complicated to explain and is content meant for an article. Fortunately, there is articles on this here on CodeProject and elsewhere on the web. To the original poster, you just have to search for the right terms, like ListView SubItem CheckBox C#[^], which came up with several results (including some here on CodeProject).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, All!
I am using PropertyGrid to edit properties of type Font, Size (e.g. standard types).
These properties are expandable in propertygrid and I need to make names of sub-properties (Font.Size, Font.Name, Size.Width etc) locale-dependent.
There are examples how to localize your own-made classes, by overriding GetProperties method (go to http://www.codeproject.com/cs/miscctrl/globalizedpropertygrid.asp or search for "GlobalizedObject", "Globalized Property Grid" to see details).
I successfully used this for my own classes, but in the case of standard classes this does not suit me well:
1) I cannot inherit from Font to just override GetProperties, Font is sealed class.
2) When I make my own class that will wrap Font instance, I will lose advanced editing in PropertyGrid, e.g. combobox with icons for font family name.
3) Also and I am confused with emulating original Font editing: Font has read-only properties Name, Size that can nevertheless be edited in PropertyGrid.
Could someone suggest me way to resolve this problem, so I will have localized sub-properties for properties of standard types Font, Size in PropertyGrid and editors in PropertyGrid for these properties will remain with all their bells and whistles?
Thanks in advance.
|
|
|
|
|
If you're using a custom TypeConverter or UITypeEditor , you can attribute the property that is of Type Font . This would take precedence over the TypeConverterAttribute or EditorAttribute that is declared for the class itself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I made type converter inherited from System.Drawing.FontConverter and override GetProperties method.
But GetProperties method of my type converter is never used.
See code below.
//////////////////////////////////////////////////
// class that should be localized
...
[TypeConverter(typeof(LocalizedFontTypeConverter))]
public Font FontProp
{
get { return fontProp; }
set { fontProp = value;}
}
...
// type convertor
...
public class LocalizedFontTypeConverter: System.Drawing.FontConverter
{
public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes)
{
return GetLocalizedProperties(base.GetProperties(context, value, attributes));
}
// GetLocalizedProperties method is omitted
}
|
|
|
|
|
Did you try putting a breakpoint on your return statement? I've done this in several apps and it works fine, depending on how the containing class is used (if you assign the containing class instance to PropertyGrid.SelectedObject for example).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes, of course. I put breakpoint in my GetProperties method and saw that this method was not called.
Class instance attached to PropertyGrid using
PropertyGrid.SelectedObject = ...
If you say that this should work, it is fine
I will continue trying.
|
|
|
|
|
How can i get the true icons of a file using c#.
When someone enters a whole path (which exist) in a textbox.
e.g. If it is "c:\tekst1.txt", how can i get the file icon. Here it is a plain text icon.
If you enter the path of a ms-word doc. I will get the ms-word icon.
Is there some class availible or need i to read the registry entries in the Classes_root. (when the registry refer to a ico-file this is no problem, but most programs refer to an exe-file.
Thanks
Jonathan Slenders
|
|
|
|
|
|
|
Hello,
Precondition.
1. The ListView control. have 5 columns.
2. This have 70 data.
I would like to remove data after add data on visual.
I could do it. but not visible.
After remove and add data on ListView and ListViewItem, I called Update() or BeginUpdate() & EndUpdate(). But These data didn't update.
The following is the source.
If you have some ideas, please tell me.
regards,
yu-yu
--------------------------------------------------------
lvListView.BeginUpdate();
while(i < lvListView.Items.Count)
{
if (lvListView.Items[i].SubItems[3].Text.CompareTo(sTemp[3]) == 0)
{
lvListView.Items[i].Remove();
break;
}
i ++;
}
ListViewItem items = new ListViewItem("WEB");
items.SubItems.Add(sTemp[2]);
items.SubItems.Add(sTemp[4]);
items.SubItems.Add(sTemp[3]);
lvListView.Items.Insert(lv参加者.Items.Count, items);
lvListView.EndUpdate();
|
|
|
|
|
Our scenario:
Multiple objects being hosted in a Windows services on Win2003 Server.
Up until now, we were running the server as an EXE, but since moving to a service all our errors are being returned as "Server encountered an internal error.".
We last saw this error when our exceptions were not supporting serialisation correctly.
Since changing the exception classes, the error went away and we haven't changed anything else since moving the server code into a service.
The code works 100% and the exceptions are expected, however the type and associated info about the exception is now not being preserved across the remoting boundary.
Is the behaviour of the remoting code different if it's in a service?
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "It'll be a cold day in Hell when I do VB.NET...", Chris Maunder
|
|
|
|
|
It shouldn't be (since a service is just an executable that's run by the SCM), but to satisfy curiousity (and hopefully help you solve the problem), have you tried checking the Exception.InnerException to see if you are getting what you expected?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
<br />
private void btnPrevious_Click(object sender, System.EventArgs e)<br />
{<br />
txtAcctID.Clear();<br />
<br />
if (Row == 0)<br />
{<br />
MessageBox.Show("You are at the first patient on the Queue","Beginning Of Queue");<br />
Row = 0;<br />
<br />
}<br />
else<br />
{ <br />
Row = Row --;<br />
txtAcctID.Text= dsPatDia.Tables["PatDia"].Rows[lastrecord]["Acct ID"].ToString(); <-- ERROR! <br />
}<br />
<br />
if( Row == 0)<br />
{<br />
try<br />
{<br />
oleDbConnection1.Open();<br />
<br />
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Results, Tests, Symptom FROM Dianosis WHERE [Acct ID]= '"+txtAcctID.Text+"'";<br />
<br />
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();<br />
<br />
oleDbDataAdapter1.Fill(dsDiag2);<br />
<br />
Display(dsDiag2);<br />
}<br />
catch (Exception ConnError)<br />
{<br />
MessageBox.Show(ConnError.ToString());<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
private void Display(System.Data.DataSet dsDiag2)<br />
{<br />
oleDbConnection1.Close();<br />
try<br />
{<br />
System.Data.DataTable PrevDiag = dsDiag2.Tables[0];<br />
<br />
if(PrevDiag.Rows.Count != 0)<br />
{ <br />
txtResults.Text = (string) PrevDiag.Rows[0][3];<br />
txtTests.Text = (string) PrevDiag.Rows[0][4];<br />
txtSymp.Text = (string) PrevDiag.Rows[0][5];<br />
}<br />
else<br />
{<br />
MessageBox.Show("The Patient Record does not exist","Information");<br />
dsDiag2.Clear();<br />
}<br />
}<br />
catch(Exception Error10)<br />
{<br />
MessageBox.Show(Error10.ToString());<br />
}<br />
}<br />
An unhandled exception of type 'System.NullReferenceException' occurred in CLINICINFORMATIONSYSTEM.exe
Additional information: Object reference not set to an instance of an object.
how do i rectify this prblem..i want the textbox to display the id of the record before the current one.?
CODER
|
|
|
|
|
There are at least two things you want to check out:
1. You probably forgot to fill the dataset before you call the methods (or even declared it as new).
2. The table does not exist, the column does not exist, or there are no records in the table.
How did you get the lastrecord variable in Rows[lastrecord] anyway?
Edbert P.
Sydney, Australia.
|
|
|
|
|
Hi ,
Find the exact line it occers. it says your object(may be oleDbConnection1 ) is still null, but your going to call its method.
D!shan
|
|
|
|
|
Hello,
most programms using a mdi container have a tabcontrol like panel showing all open windows for a fast switching. is there any avaible control for this, or dokumentation how to build such a feature?
thanks
|
|
|
|
|
Not provided in the FCL (.NET Framework Class Library), no. There are many third-party controls out there that do this, however, like .NET Magic Controls[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey
i Got a Access data base file that i whant to open in C#, i use the folowing code
<br />
<br />
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=testdb.mdb");<br />
using(conn)<br />
{<br />
OleDbCommand com = new OleDbCommand("SELECT Medelande FROM Medelande",conn);<br />
using(com)<br />
{<br />
OleDbDataReader r = com.ExecuteReader();<br />
using(r)<br />
{<br />
this.txtBoard.Text = r["Medelande"].ToString();<br />
}<br />
}<br />
}
It says "ExecuteReader requires an open and available Connection. The connection's current state is Closed."
The file is in the projects dir and the file is named testdb.mdb .
Why is this not working? do i have to start a SQL Server? I have One SQL Server installed, but how do i get this server to know that i what to use this testdb.mdb?
And how do i rewrite the code so it takes contact with the SQL server instead?
//Jimmy
|
|
|
|
|
Hi...
Try using this:
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\mypath\\myDB.mdb");<br />
<br />
OleDbCommand com = new OleDbCommand("SELECT Medelande FROM Medelande",conn);<br />
<br />
conn.Open();
<br />
OleDbDataReader reader = com.ExecuteReader();<br />
...<br />
...<br />
<br />
conn.Close();
|
|
|
|