|
Hello,
i've seen that the most common Windows Forms controls have the property BorderStyle. I've designed some forms with all the controls with FixedSingle like border. But the ComboBox have not, yet, that property. Is there a simple way to change the border? the combo seems too much different to the other components in the program, i'd like to uniform the style.
Thanks
|
|
|
|
|
|
thanks i'm looking into it
|
|
|
|
|
There's several other articles about this on this site as well in C# (though the syntax would be the only thing different between VB.NET and C# code). Just some other alternatives that shouldn't be hard to find if you search CodeProject (say "flat combo" or something like that).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello all
I have been trying for some time to write a good line control using C#. By this I mean a line control that can be used in graphical diagrams, graphic design programs and so on, to draw a line between two arbitrary points.
I believe this topic hasn´t been covered before, I´m trying to write an article on this but I have found a few problems which I can´t solve (I´m still new to .net and c#). Here it goes, I hope you guys can help me!
First, I inherit a control from System.Windows.Forms.Control. I override the OnPaint to draw a line between two corners of the control. This doesn´t work too well because you can´t see any of the controls that are behind the line´s control region. In other words, you get a nice white rectangular area encompassing the line and covering all that surrounds it.
Then I tried playing with various background colour settings. Interestingly, the "transparent" colours do not allow you to see what´s behind the control´s region - sure enough, it lets you define an alpha value for the background colour but you can´t see through it. Anyway, I also tried overriding OnPaintBackground, and playing with the control styles (UserPaint, SupportsTransparentBackColor, AllPaintingInWmPaint).
Lastly, I tried changing the control region of the line for a polygon that would more or less exactly encompass the actual line. So you only get a "white" area on a small polygon around the line instead of on a big rectangle. Guess what, although this looks quite nice there are occasions where windows doesn´t like it at all: when two of these lines are overlapping and are both moving at the same time, the system slows down a lot, and the rest of the controls aren´t correctly re-drawn.
As you can see, I´ve done my homework before asking. Can anyone give me a hand please? I just want a control to draw a line between two points :´(
Thanks in advance
-a.
|
|
|
|
|
hi,
I'm not sure why you want to make it as a control when this can be done directly.
Take the graphics object of the control on which you want to draw the line, and then graphics object gives the method "DrawLine" which takes two "Point" object for 2 corners of the line and you are done.
someControl.CreateGraphics().DrawLine(pen object , Point object , Point object);
Hope this will help you...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
hi, thanks for your reply.
well the whole point of having it in a control is to allow the user to drag the lines around, and so that the line can receive messages from other controls, for example.
Otherwise you have to build the control yourself, and replicate lots of code inside the parent form, for example to detect when the user clicked on the line and so on. That seems a bit crap, I really would not like to go that way.
|
|
|
|
|
Basically, you just need a surface that either hosts additional controls or handle all the movement of graph objects. The graph objects should maintain connection points to other graph objects so that when they move the lines is drawn between the connected graph objects even as they move.
There are a couple articles here on CodeProject that should introduce you to a couple different ways of doing this. You can either do a search or navigate the categories from the homepage.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am doing the coding in C# for bluetooth devices(PPC tp Bar code Scaner).For that i need to stablish connection.There are some function like SOCKET, SOCKADDR_BTH,memset & connect etc. which need ws2lib ,ws2.dll file.I tried to search it,buti chouldn't find.
Regarding this matter can anyone do some help.anyone have ws2.lib or ws2.dll file.
Thanks
Pradeep
|
|
|
|
|
ws2.dll and Bluetooth were first supported in Windows CE 4.0 (Pocket PC 2003 for consumer devices). Earlier devices optionally supported Bluetooth but used their own APIs rather than Winsock.
If you have a suitable unit, ws2.dll will be in the ROM of the device. It may not be displayed through ActiveSync's Explore function.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
can anybody tell me the way how I can determine wheather an assembly is managed or not programatically. I need to load the assembly at runtime and then need to dertermine wheather its managed or unmanaged.
thanks in advance,
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
If it is not managed, you will get an exception.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
thanks man... i guess this will work.
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
|
It you'd like an easy way to determine if something is an assembly in Windows Explorer (I know this isn't what you're looking for, but you might like it anyway), see my free shell extension on this site - with source included - Shell Extensions for .NET Assemblies[^]. A couple column providers are also provided to custom a detailed view in Windows Explorer.
There's also code in there that shows how you determine if an executable is an assembly or not by navigating through the virtual tables in the PE/COFF header. There is a managed way to do this as well, but I can't seem to find it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The folllowing code I create a Listview with 550 Columns.
Now when you scroll to the end, the headers arent diaplyed correctly, but the data is OK. It appears there is a limit on the size the Columnn Headers can draw in.
Has anybody else has this problem?
Is there a work around for it?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication6
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// listView1
//
this.listView1.Location = new System.Drawing.Point(16, 32);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(256, 208);
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.listView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
for(int i =0; i < 550; i++)
{
System.Windows.Forms.ColumnHeader colHead = new System.Windows.Forms.ColumnHeader();
colHead.Text = "TQQ" + i;
listView1.Columns.Add(colHead);
}
ListViewItem item1 = new ListViewItem("Test");
for(int i =0; i < 550; i++)
{
item1.SubItems.Add(i.ToString());
}
listView1.Items.Add(item1);
}
}
}
|
|
|
|
|
Nothing is documented in the Header common control documentation as being a hard limit, but with so many columns I would venture a guess that memory consumption is likely the problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I want to assign special keys (like F2,F3...) to operation.
Like the accelerate table that is in MFC.
Tell me if there is a way to do that without catching the key down.
I know i can do it with windows API (Hooks) but i want mor elegant way.
Thanks,
Adam
|
|
|
|
|
A good way using global application shortcuts is to implement the IMessageFilter interface and add it using Application.AddMessageFilter . This implementation could either hard-code shortcut keys (handling the notification messages such as WM_KEYDOWN (0x0100)) or use a map file so that a user can define their own shortcuts if such functionality is desirable. Make sure your implementation is efficient, however, since all messages throughout your application will be routed through this interface (it hooks the message pump).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
To me Reflection.Emit and OpCodes are a cryptic way to generate code. I'm wondering if the System.CodeDom.Compiler namespace provides equivalent functionality. In particular it seems possible to use CSharpCodeProvider to compile C# code to assemblies.
Is this true, and if so what are the disadvantages and advantages of Emit and Opcodes vs CSharpCodeProvider? Also if my application uses CSharpCodeProvider and code compilation will it be deployable on all systems supporting the .net platform?
Thanks,
Ben
|
|
|
|
|
The CSharpCodeProvider is a Microsoft extension to the CLI so it may not be supported in, say, Mono.
As far as the differences between the two, however, Reflection.Emit should be available on all platforms. Another difference is that you can use Reflection.Emit without generating source files to compile using a CodeDomProvider. They are both ways of generating assemblies at runtime, it's really more of a question about which suits your needs.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a Mobile App running on PocketPc 2003 OS. My connection to a Sql database is not consistent. What design should I go with in order to store data locally and when connection is made download data to database ? Should I use maybe web services or MSMQ? Any ideas please?
Im leaning more toward MSMQ since their is a trigger mechanism to test for connection to other computer. What do you think?
Thanks,
JJ
|
|
|
|
|
Um, did you read my post to your previous, similar question? Use SQLCE and replicate with the MSDE or SQL Server database. It's simple.
See Designing "Sometimes Off-line" Microsoft .NET Compact Framework Applications[^] for an article about this.
Basically, IIRC there's a little install you run on the server that enables replication with a SQLCE database. When your device syncs with the server (or your desktop, whichever) the database is replicated. No code to write in such a case and you can take advantage of pretty much all the replication features, such as not firing certain triggers during replication.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have created several ASP.NET server controls, but this is my first attempt at a control for Windows Forms. I need to build a control that has no visual component (for example, like an ImageList control).
When I inherit from Control, it brings along a ton of properties and methods that I don't need or want (i.e. backcolor, font, anchor).
What should I inherit from in order to create a control with no design time or visual properties? Just the properties and methods I dictate?
-Todd Davis (toddhd@hotmail.com)
|
|
|
|
|
Are you sure you want to create a control? Todd Davis wrote:
no design time or visual properties? Just the properties and methods I dictate?
Sounds like you just want to define your own class.
class ToddsClass{
public int ToddsInteger;
public int ToddsMethod(int iFactor){
return(iFactor*this.ToddsInteger);
}
public ToddsClass(){
this.ToddsInteger=1;
}
}
Or am I missing something?
Bill
|
|
|
|