|
|
|
NaNg15241 wrote: how will I be able to drag the window?
A very easy way to do it is to override WndProc on your form, handle WM_NCHITTEST , call the default, and if it returns HTCLIENT , change it for HTCAPTION . You'll be able to drag the form around by clicking on the client area.
I'm at home right now, but if you need help on that (or sample code), reply to this post and I'll show you some sample code that I have at the office. Those constants (WM_NCHITTEST , HTCLIENT , HTCAPTION ) can be looked up in Windows.h .
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
-- modified at 23:42 Sunday 12th March, 2006
|
|
|
|
|
This code will create a form that can be moved by dragging from the client area:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int WM_NCHITTEST = 0x84;
const int HTCLIENT = 1;
const int HTCAPTION = 2;
const int HTSIZE = 4;
const int HTBOTTOMLEFT = 16;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
{
if (m.Result == (IntPtr) HTCLIENT)
m.Result = (IntPtr) HTCAPTION;
}
}
}
I hope it helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
I am trying to keep a window open by handling the MouseMove event. However, the event is only ever raised when the cursor is over the splitter bar between the grid and description. Any help/suggestions?
|
|
|
|
|
I take it that you're capturing the Form.MouseMove event?
If so then what's happening is that the Grid and the Description are on top of the form and are blocking the mouse-movement for the form (basically).
The simplest way around this would be to set the Grid.MouseMove and Description.MouseMove events to be handled by the same handler as the form.
To do this, select the grid, click the events tab on the properties window in the form designer. You should be able to select the Form_MouseMove (or whatever it's called) routine in the MouseMove combo-box for the grid (they have the same delegate handler so they're compatible).
Repeat the process for the description.
Ed
|
|
|
|
|
Hi.
I have a DataGrid and ListView.
I want, when a row is added to datagrid by user, It displays in ListView too.
How can I do it?
Best wishes
|
|
|
|
|
Hi.
I have a collection( It write it) .
In a form I want to use a datagrid that when a user fill a row of it the contents, insert in collection.
In other words, with fill datagrid by user, my collection fill.
Please help me I this context.
Best wishes
|
|
|
|
|
Your datagrid usualy is bound to the dataTable that holds the data shown into you grid. Sou you must intercept the changes that ocur into the dataTable. This can be obtained with these events :
DataTable.RowChanging/DataTable.RowChanged
DataTable.RowDeleting/DataTable.RowDeleted
Intercept change to the table and update you collection.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hello, I am looking for a way to get something similar to the tables that are seen in Word. I can draw a table onto a RichTextBox control using the appropriate RTF syntax, but what I would ultimately like is the ability to resize columns and rows using the mouse.
Does anybody know how this is done? Is there a third party control that allows this to happen?
I suppose you could trap mouse movement and such, but this seems really hard, because how would you even know where the table is within the textbox?
Thanks in advance,
Eric
|
|
|
|
|
Hello,
When coding a dialog box in C#, naturally there is going to be code that loads the dialog box with its initial values, responds to user input, and then retrieves the new values for use in the application.
Is it more appropriate to put this code into the Form class of the dialog box itself, or to have a separate class whose job it is to control the dialog box, and interface with it?
Thanks,
Rich
|
|
|
|
|
Troposphere wrote: Is it more appropriate to put this code into the Form class of the dialog box itself, or to have a separate class whose job it is to control the dialog box, and interface with it?
IMO, neither. Use data binding to connect an autonomous class that contains the properties for the data with the dialog. The data binding ensures that neither the dialog nor the underlying container class needs to know about each other, which makes your application more flexible and extensible. Here's[^] an article I wrote on the subject.
Marc
Pensieve
Functional Entanglement vs. Code Entanglement
Static Classes Make For Rigid Architectures
|
|
|
|
|
Thanks Marc! Your article is right on the money. And I really think your website is slick!
Rich
|
|
|
|
|
How do i change the background colour of a tabcontrol? I looked at msdn and i found .BackColor property but it doesnt seem like its working...
|
|
|
|
|
In order to draw my own font on the tab page i have overridden TabControl.DrawItem using the following:
private void DrawOnTab(object sender, DrawItemEventArgs e)
{
Graphics g = e.Graphics;
RectangleF tabTextArea;
TabControl tc = (TabControl)sender;
SolidBrush brush = new SolidBrush(Color.Black);
Font fnt = new Font("Microsoft Sans Serif",14F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
foreach (TabPage tp in tc.TabPages)
{
tabTextArea = (tc).GetTabRect(tc.TabPages.IndexOf(tp));
//find out how to draw the string center
g.DrawString(tp.Text.Replace('_', ' '), fnt, brush, tabTextArea);
}
}
Right now it draws the text aligned to the left, how do i draw the font center? do i have to calculate the length of the string manually? How do i do that?
|
|
|
|
|
Use the version of Graphics.DrawString() that allows you to specify formatting options. See this[^] link.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I am using the cards.dll in my application as suggested at this website:
http://www.publicjoe.f9.co.uk/csharp/card06.html
The card shows up just fine on the form but i get this weird message immediately after drawing:
-----------
A call to PInvoke function 'CardMgr!cards.cardsdll::cdtDraw' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
------------
I have no clue what information to include in this to even begin to addrss the problem.
Any ideas how to address this?
Thanks!
|
|
|
|
|
|
Thank you so VERY VERY VERY much, Ravi.
That resolved the problem ... the DLL returned an integer ... the interface expected a bool.
I will so inform the author of the website ... thanks again.
|
|
|
|
|
I want my tabpage to be scrolled by using my own button, so I have the following:
if (tabControl1.SelectedTab.VerticalScroll.Value - 200 > tabControl1.SelectedTab.VerticalScroll.Minimum)<br />
{<br />
tabControl1.SelectedTab.AutoScrollPosition = new System.Drawing.Point(0, tabControl1.SelectedTab.VerticalScroll.Value - 200);<br />
}else<br />
{<br />
tabControl1.SelectedTab.AutoScrollPosition = new System.Drawing.Point(0, tabControl1.SelectedTab.VerticalScroll.Minimum);<br />
}
this is the event handler method to clicking the button for scrolling down
When i click the down button, it only moves down once, the second time i click it it doesnt work any more...
this happens when i have the AutoScroll disabled, but when i have autoscroll enabled, its fine
why!?
Can someone help me? is there anyway to enable the autoscoll, but hide the scroll bar?! maybe override the onPaint method for tabControl?
|
|
|
|
|
I have a database in which users can upload files for storage and whatnot. In my windows forms app to download/upload I am displaying the files that the user has uploaded. In the ListView I would like to display the appropriate icon for each file.
ex: If they have Microsoft Word installed, it should display a Microsoft Word icon. If not just a plain file icon should be displayed.
How would I do this?
Any help is appreciated.
|
|
|
|
|
Perhaps you could call SHGetFileInfo to obtain the file's icon index in the system image list (as well as its display name, eg: "Microsoft Word document"). You can pass a fictitious filename (with a matching extension) to SHGetFileInfo .
See this[^] link for how to call ShGetFileInfo from your WinForms app.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Looks like that is what I need. Thanks!
|
|
|
|
|
Hello ,
Read a article on mobile agent on code project,its wonderfull.
Also i read an article on mobile agent on MSDN
link to the article :
http://msdn.microsoft.com/msdnmag/issues/06/02/MobileAgents/default.aspx
It also conist of sample code implementation of mobile agent,its in C#.NET
i tested the program on the LAN,but got errors like
1>No connection could be made because the target machine actively refused it
or
2>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
also tried between 2 PC's but got the same error.
Also i am new to .NET
can anyone help
thanking anyone in advance
karthik
|
|
|
|
|
Hi! I have a newbie question: How do I get this code to compile and output "derivedclass"? The classes may only have static methods.
class BaseClass
{
static string _name = "baseclass";
static string GetName()
{
return _name;
}
}
class DerivedClass : BaseClass
{
static string _name = "derivedclass";
}
Console.WriteLine(DerivedClass.GetName());
I'm stumped so any help would be appreciated.
- Phil
|
|
|
|