|
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
|
|
|
|
|
Use:
static new string GetName() {...}
|
|
|
|
|
Unfortunately, that doesn't work.
|
|
|
|
|
I'm a beginner programmer and,
I've been having problems with passing the values of global variables from one form to an other.
can some one help me.
I searched the webpage but couldn't find an easy way to do it.
thanks in forward
programming should sometimes be more logical.
|
|
|
|
|
first create second form on your first form after then you can call public variables of your form1 using Form1.yourPublicVar . i mean on buttonclick event write code like this
mySecondForm Form2 = new mySecondForm();
Form2.yourPublicVar = what you want;
openup your heart and let the sun shine in
|
|
|
|
|
I don't seem to be able to extract the public variable...
I did everything you said, can you make a sample project and sned it to me??
If so please reply....
thanks in forward
sorry I'm just a noobie
|
|
|
|
|
i am busy now but if you wait i will make a sample project for you (about 10 hours later)
openup your heart and let the sun shine in
|
|
|
|
|
THNX, let me know if you have it
|
|
|
|
|
i sent you a win project about transferring variables between forms i hope it helps you
bys
openup your heart and let the sun shine in
|
|
|
|
|
I am trying to develop a C# library that will be used by other class libraries in our orginization. I am have great difficulties in getting our other class libraries to be able to call methods of this library. We can create an instance of the public classes in my library but are unable to call any of the public methods or properties (even static ones) of that instance. Can anyone make a suggestion as to what I am missing here?
|
|
|
|
|
Give us more information.
What version of the framework are you using, how are you refrencing the DLL, are you getting any erros, if yes what errors, some code would be nice too...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|