|
I need list control like the following: each item consists of several fields (such as filename/extension/size/date of creation etc.) with some simple actions like remove/add selected components and drag&drop.
Can anybody help? I'll very thanksfull
|
|
|
|
|
Why don't you use the standard ListView control?
1) In the "properties" box choose "Columns" and add a column for every field.
2) Check e.KeyCode in the "KeyDown" event method to remove items:
<br />
if((e.KeyCode == Keys.Delete)&&(listview.SelectedItems.Count > 0)){<br />
listview.Remove( listview.SelectedItems[0] );<br />
}<br />
3) In the "ItemDrag" event method call listview.DoDragDrop(e.Item, DragDropEffects.Move);
Now you can drag items.
4) To drop items set "AllowDrop" to "true", and fill the event method for "DragEnter" and "DragDrop".
Conclusion: .NET contains all you need (as long as you don't want to sort the items).
|
|
|
|
|
Actually, you can sort the items as well. The ListView does provide for that via the ListView.ListViewItemSorter property. There's several articles about using this and various alternatives for implementing the IComparer here on CodeProject.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I am trying to create a customisable - bordered TextBox control. I draw the border in the overrided method OnPaint, after I have previousely set the UserPaint style bit.
I don't understand why the setting of the UserPaint flag makes the text within the textbox change its font.
My example can be reduced to this :
public class testTextBox : TextBox
{
public testTextBox()
{
//
// TODO: Add constructor logic here
//
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
SolidBrush sb = new SolidBrush(Color.Red);
Pen pen = new Pen(sb, 1);
e.Graphics.DrawRectangle(pen, 0, 0, 10,10);
sb.Dispose();
pen.Dispose();
}
}
I tried to do the drawing of the string myself, but the font kept changing back.
Can anyone help, please?
|
|
|
|
|
The reason you are having a problem with this is that Windows draws the text of the Textbox and Richtextbox. Thus, when you use the OnPaint override, Windows goes crazy trying to draw the text as you go crazy trying to draw the border. Instead, try taking a screenshot of the textbox into memory, then drawing on to the screenshot. Then, copy the modifed screenshot onto the textbox.
Sorry I can't give you the actual code for this, but you seem to have a decent handle on GDI+.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Hi,
I have a datagrid and I want checkboxes along with a text beside it on each column header. How do I do this??
KArteek
|
|
|
|
|
You can add regular checkboxes to the form containing datagrid, and then simulate, that they are part of datagrid: probably you'll need to serve scrolling and column resizing events, to position them properly.
I can send something similar next week if you want.
h.
|
|
|
|
|
Hi,
I want check boxes only in the column header. Not for full column.
Karteek
|
|
|
|
|
|
I have new project, it's name MailMonitorService.
I create new project in Windows Service Application and try to create TcpClient for connect to web.
it' can compile but when i start service it's tell me Type Initialize exception. I dont' know, Why?
Who can tell me ?
Why not create socket under windows service?
And This is my source code.
http://www.buycoms.com/mailmonitor.zip
Thanks everybody.
|
|
|
|
|
I am created a simple compoent with designer(including on verb called GenerateDataSet).
namespace Main
{
[DesignerAttribute(typeof(CDSGeneratorDesginer), typeof(IDesigner))]
public class CDSGenerator : System.ComponentModel.Component
{
public CDSGenerator()
{
}
}
public class CDSGeneratorDesginer : System.ComponentModel.Design.ComponentDesigner
{
public override System.ComponentModel.Design.DesignerVerbCollection Verbs
{
get
{
DesignerVerbCollection objVerb = new DesignerVerbCollection();
objVerb.Add(new DesignerVerb("Generate Dataset",new EventHandler(GenerateDataSet)));
return objVerb;
}
}
public virtual void GenerateDataSet(object sender, System.EventArgs e)
{
CDSGenerator objCDS = ( CDSGenerator ) this.Component;
DataSet dsSample = new DataSet();
DataTable dtEmployee = new DataTable("dtEmployeee");
dtEmployee.Columns.Add(new DataColumn("dcEmpID")) ;
dtEmployee.Columns.Add(new DataColumn("dcEmpName")) ;
dsSample.Tables.Add(dtEmployee);
objCDS.Container.Add(dsSample,"dsSample");
}
}
}
The dataset adding to the form. The datatable and columns are not entered in .cs file but going to properties of dataset via property grid, the tables and columns are availabe.
|
|
|
|
|
Dear All,
I am looking for a Open Source C# for POP3 with attachment base on .Net framework 1.1 and special support HTML encode/decode if everyone know where on internet can download that open source.
Thank you advance,
TungBui
|
|
|
|
|
You're looking for open source so you can just rip off the code? Perhaps you should try learning the POP3 specification. Here's the RFC (RFC 1939): ftp://ftp.rfc-editor.org/in-notes/rfc1939.txt[^].
As far as encoding, you can really use about any you want but UUEncode and Base64 are most common (Base64 is most common between those two these days). Support is already provided in .NET 1.x using the Convert.ToBase64String , Convert.FromBase64String (and related - used for small blocks of text or binary data), ToBase64Transform and FromBase64Transform (for small and larger blocks of text or binary data).
If you don't need the code, then there are countless POP3 clients available. You can find both them and code by doing a google search[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi guys,
I guess it's a pretty easy question for you. How do you check if a Windows Form (object) is already loaded in C#?
Thanks!
|
|
|
|
|
What exactly doyou mean?
If you want to know it from within the form - just use OnLoad event. Thing goes worse if you want from out of the form. Maybe you should look for some threading topics? (ie. static semaphores set from OnLoad)
h.
|
|
|
|
|
What do you mean? Are you talking about an MDI Child form?
In any case, your code should be written to track this information as it happens. Your code is the only thing that is going to load and instantiate the form so tracking this is pretty easy...
RageInTheMachine9532
|
|
|
|
|
Yes, I mean the MDI child form, because it can be loaded multiple times. We just want to have one form at a time.
|
|
|
|
|
Great! When your app creates the child form, just set a global flag that says the form has been created. When you go to create the child form, just check the flag first. Done!
RageInTheMachine9532
|
|
|
|
|
Can I do this:
private someForm form;<br />
<br />
if (form == null)<br />
form = new someForm();
Also, is form = null when disposed? How do I know if a form is disposed?
Thank!
|
|
|
|
|
Actually you do both, call the Dispose() method and set the variable to null. Dispose will tell the instance to release the resources it holds while setting the variable to null will release the reference to that instance.
Calling Dispose will release the resources when YOU want it to and not when the garbage collector gets around to calling Dispose for you. When you set your variable to null, the reference to that instance is dropped and, since you already called Dispose, the garbage collector only has to free the memory that the instance occupied. When you do both Dispose and null, you release resources and memory much quicker than if you waited for the GC to get around to it.
RageInTheMachine9532
|
|
|
|
|
I have been experimenting with Web Service Extentions WSE 1.0 (v1.0.2312) and initially fine until I tried to send an attachment back to the client. From the messages it appears the responce SOAP message and attachment are being correctly generated but I am missing something in being able to recive the response. The error message is:
Client found response content type of 'application/dime', but expected 'text/xml'.
I see not place to change the content type of either what the server is sending back (well yes but see below) nor what is valid for the receive.
Some notes the Service now has the Microsoft Web services
using Microsoft.Web.Services;
using Microsoft.Web.Services.Dime;
The web.config has the extentions defined
<system.web>
<webservices>
<soapextensiontypes>
<add type="Microsoft.Web.Services.WebServicesExtension, Microsoft.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0">
.....
The stub code in the client does not have the Microsoft.Web.Service defined
The clint code does have the Microsoft.Web.Service defined.
When I look at the WSDL I see nothing that would indicate the client should expect one content type over another. I actually expected this but then I should be able to accept (or limit) valid types in some definition on the client.
I do not see where to set what the response type should be. I can set it on the server but when I add the attachment it corrects that, which I think it should be doing but would like to override it (I am sure I would have a reson some time.)
I do think that I should be able to specify on the client what is correct.
Any helpful hints?
I do not mind getting old. It beats all the other options that can think of.
|
|
|
|
|
Ok, Found what I was skipping.
In the proxy class / what I called the stub above it does need the Microsoft.Web.Service defined and
the base class must be changed from:
public class WSE1 : System.Web.Services.Protocols.SoapHttpClientProtocol
to:
public class WSE1 : Microsoft.Web.Services.WebServicesClientProtocol
both of these are manual edits and I expect will be destroyed if you reimport the WSDL.
Life is agian good.
I do not mind getting old. It beats all the other options that can think of.
|
|
|
|
|
Can ianybody tell me how i use tapi v3.0,for communicating b/w 2 computers connected to LAN via networks cards.because the samples i saw requires modem,but can 2 computers communicate using tapi and have only network cards.please give me some application for this.
mughalali
|
|
|
|
|
What do you mean by "communicate"? What do you want to send between the machines?
RageInTheMachine9532
|
|
|
|
|
simple data,i want client-server prog, exchange data with the help of TAPI technology.i also donot know much about tapi and its capabilities.please give some sample code which exchange data b/w 2 computers using TAPI
mughalali
|
|
|
|