|
In the standard Contextmenu you can't add an Image. You'll either have to write a derived class with it's own OnDraw method or build an Enxtender.
Or you download one of the existing open source menu / Context Menu systems, like Magic Library or Sandbar...
|
|
|
|
|
I am writing a form-based program with 2 forms: main & child.
The main form call the child form as:
frmChild child = new frmChild();
child.ShowDialog();
The problem is that in the child form, I want to change some properties of the main form (like button.Text, labels, etc). I also want to call some functions declared in the frmMain class.
I tried to use the Intelli Sense of VS in child, but when I type frmMain., it doesn't show up both the form main controls and the public functions declared in the frmMain class.
Can anyone intruct me how to do this ?
Thank you very much for your help.
|
|
|
|
|
assume your parent forms class is "MyParentForm"
what you want to do in your child for is this:
<br />
MyParentForm frmParent = (MyParentForm)this.Parent<br />
this way you get to all the properties and public fields/methods of your parent form
|
|
|
|
|
Sorry but it doesn't work at all.
VS didn't complain anything during compilation. However, during runtime, I got an exception saying:
Object reference not set to an instance of an object.
The watch window shows that frmParent (in your example) is an undefined value.
============
assume your parent forms class is "MyParentForm"
what you want to do in your child for is this:
MyParentForm frmParent = (MyParentForm)this.Parent
this way you get to all the properties and public fields/methods of your parent form
|
|
|
|
|
when you declare the child form in the parent form you must initialize the parent property of the child form before calling show() or showdialog()
EG. ChildForm frm = new ChildForm() ;
frm.parent = this ;
frm.ShowDialog() ;
|
|
|
|
|
The Parent object is not available in the Constructor yet (because it won't be set until the ShowDialog method is called). I usually set my references to the parent form in the Layout Event and add a LayoutCalled bool to the class so the references will only be set once....
|
|
|
|
|
Thanks for your advice, gurus
It's working now with a few tweaks.
|
|
|
|
|
Hello,
I have a question.
I'm develop chat tool.
I usually use MSMessenger. The send message dialog of this have two areas, write message board and message log board.
And the bordor move smoothly.
I would like to develop this function using C#.
I look for some controls, try to several way, but I couldn't.
If you have some solutions, please tell me on detail.
regards,
yu-yu
|
|
|
|
|
Is the Splitter control what you're looking for?
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.
|
|
|
|
|
Hello John,
Yes, like Splitter control.
But VS.NET 2003 don't have splitter control of Up-Down.
I found it of Right-Left.
yu-yu,
|
|
|
|
|
Hi,
I have one question, how can I get the logic drive space infomation?
As my program will do some file copy functions, so I need to check whether it has enough space to paste. I hope to know the how much it remains and its total space..
I've checked the Directory class, no this method I can use, so could anyone help me?
Thank you.
|
|
|
|
|
You can choose to use the native Win32 API functions through P/Invoke. Or you can go the modern and more elegant way of using the Windows Management interface classes of the .NET framework.:
<br />
using System.Management.Instrumentation;<br />
using System.Management;<br />
<br />
ManagementClass mcDriveClass = new ManagementClass("Win32_LogicalDisk");<br />
ManagementObjectCollection mocDrives = mcDriveClass.GetInstances();<br />
foreach(ManagementObject moDrive in mocDrives)<br />
{<br />
<br />
if (int.Parse(moDrive.Properties["DriveType"].Value.ToString()) == 3 || int.Parse(moDrive.Properties["DriveType"].Value.ToString()) == 4)<br />
{<br />
String sDeviceId = moDrive.Properties["DeviceId"].Value.ToString();<br />
long dSize = long.Parse(moDrive.Properties["Size"].Value.ToString());<br />
long dFree = long.Parse(moDrive.Properties["FreeSpace"].Value.ToString());<br />
}<br />
}<br />
mocDrives.Dispose();<br />
mcDriveClass.Dispose();<br />
For more info on the Win32_LogicalDisk management class see
Win32_LogicalDisk class @ MSDN[^]
|
|
|
|
|
Thanks,
but I don't know why I can't include System.Management namespace.
Actually, is it no any build-in class that we can use to get the volume of drive?
do you have any example about using Win32 API for this problem?
|
|
|
|
|
you need to add the reference to System.Management.dll
Right click on "References" in Solution Explorer choose "Add Reference" and find the dll in the list. I don't see why you would want to use the unmanaged way as it is less elegant then the .NET way but you need to use GetLogicalDriveStrings function from kernel32.dll and GetDiskFreeSpaceEx function also from kernel32.dll. Look these up on MSDN.
|
|
|
|
|
Hi All,
I have a C# Windows Form, which contains a DataGrid, and one of the column in the DaatrGrid is Checkbox.
What I need to do is - when checkbox is checked, all other checkboxes should be unchecked.
For ex: if there are 10 rows in DataGrid, and Row - 2 has checkbox checked. Now when "Checkbox column of Row - 5" is clicked, it should un-check "Checkbox column of Row - 2" . Please let me know how can I capture check_event and loop through all rows.
Any help or pointers
Thanks in Advance
Ruchi
|
|
|
|
|
Actually, it's not a CheckBox . A check box is merely drawn by the DataGridBoolColumn using either ControlPaint.DrawMixedCheckBox or ControlPaint.DrawCheckBox , depending on whether or not the column allows nulls (DBNull ).
If you want to use an actual CheckBox and expose the event (better to encapsulate the CheckBox and expose only what's needed), you'll have to derive your own DataGridColumnStyle . See the documentation for that class in the .NET Framework SDK, which also includes a sample using a DateTimePicker control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Oh, I almost forgot: if you're using a DataSet or DataTable for binding, you can handle the DataTable.ColumnChanging or DataTable.ColumnChangeed event and then enumerate the DataRow</coe>s in the <code>DataTable and change what you need accordingly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks so much for your response. I will work towards this pointer
Ruchi
|
|
|
|
|
Is it possible in C# to create a web control which allows user to draw lines, circles, shapes etc and then save it as an image?
Thanks.
|
|
|
|
|
I think its client side working so if you use ASP.NET , you have to do a lot of client side scripting which means this part is not C#. If you want to do it all in C# it takes a lot of resource,time or postback to server which does not worth to do it.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
There is an example that does just that in the book 'ASP.NET - Second Edition'. The down side is that there is a round trip to the server with every single box or line that is drawn. It works, but is hardly what I would call 'useful'.
RageInTheMachine9532
|
|
|
|
|
What if I create a window form which does all and then use it as an activex on web page. Would that be possible?
Thanks guys.
|
|
|
|
|
AWebDude wrote:
What if I create a window form which does all and then use it as an activex on web page. Would that be possible?
As me and other CPains told you thats possible but it cause lots of round trip in the server. Using ActiveX if do all the job in the client side, then post the final result to the server is good idea.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
You'll have to write a bunch of code for drawing, repainting, and something to save. But, Visual Studio.NET doesn't target building an ActiveX control natively. Your best best for this project is to use client-side Java.
RageInTheMachine9532
|
|
|
|
|
You could use a smart client but this would require .net be installed on the users pc.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|