|
To be very specific, i have to check the disk space.
Thanks.
|
|
|
|
|
Hello,
I would suggest you to add reference for the System.management class in your project and I hope that following code will return the free physical memory
Dim freeMemory As New ManagementClass("Win32_OperatingSystem")
Dim memory As ManagementObjectCollection = freeMemory.GetInstances()
Dim memEnum As ManagementObjectCollection.ManagementObjectEnumerator = memory.GetEnumerator()
memEnum.MoveNext()
MessageBox.Show("Physical memory total space is: " & Format(Integer.Parse(memEnum.Current.Properties("FreePhysicalMemory").Value) / 1024, "#,### KB"))
I hope this helps.
James Smith
James Smith
www.componentone.com
|
|
|
|
|
I'd like to know can i print something that is in textBox or a listBox.
example of code:
dim output as String =txtInput.text
txtDisplay.text = output
I do i print this out? Thanx
Faruzzy.net!
|
|
|
|
|
Hello,
To print the text in a textbox, you would have to use the PrintDocument object. Using the
PrintPage() event for this object, you can set the printing preferences and the text to be
printed.
Lets say, you have a Textbox and a Button placed on a form. Drop a PrintDocument object on
the form from the toolbox.
In the Button_Click event, write the following code:
Me.PrintDocument1.Print() ' PrintDocument1 is the name of the PrintDocument Object.
Now in the PrintPage() event for PrintDocument1 object, place the following code:
(You can double click on the PrintDocument1 to get to the event)
Dim control As Control = TextBox1 ' you can change this to control of your choice
Dim myfont As Font = control.Font
Dim mybrush As New SolidBrush(control.ForeColor)
e.Graphics.DrawString(control.Text, myfont, mybrush, 12, 12)
mybrush.Dispose()
I believe this should help.
Regards,
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
Hi, Can someone please tell me how i can use an hovergradientButton, it seems that i have to import a class from the library or something like that, since i cant see that button in my toolbox...
Faruzzy.net!
|
|
|
|
|
Your best source of information on using a third-party library is the manufacturer of the library itself.
But, generally, you add a reference to the .DLL file that's supplying the library, then import the namespaces you need to use whatever classes you need.
For controls, you can add them to the ToolBox by right-clicking a tab in the ToolBox (while you have a form window open) and picking "Choose Items...". In the dialog that shows up, you click the Browse button and go find the library .DLL file and open it. The rest should be obvious.
|
|
|
|
|
Hello,
I am using VS2005 (Framework 2.0)
I am trying to share a folder through network.
I found 2 different codes that work perfectly.
The only thing I need is the sharing to be readonly.
Here is the first code:
Try
' create a directory
Directory.CreateDirectory("C:\ScanUtilityFiles")
' Create a ManagementClass object
Dim managementClass As New ManagementClass("Win32_Share")
' Create ManagementBaseObjects for in and out parameters
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
Dim outParams As ManagementBaseObject
' Set the input parameters
inParams("Description") = "My Files Share"
inParams("Name") = "My Files Share"
inParams("Path") = "C:\MyShareFolder"
inParams("Type") = 0
' Disk Drive
' Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)
' Check to see if the method invocation was successful
If CInt((outParams.Properties("ReturnValue").Value)) <> 0 Then
Throw New Exception("Unable to share directory.")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Here is the second code:
Dim info As New ProcessStartInfo()
info.UseShellExecute = True
info.WindowStyle = ProcessWindowStyle.Hidden
info.Arguments = "/c net share ScanUtilityFiles=C:\My Share Folder"
info.FileName = "cmd"
System.Diagnostics.Process.Start(info)
Please Help
Shay Noy
|
|
|
|
|
Could you show a little damn patience and stop posting the same question every flippin' day, please? You're spamming the forum with this.
Your code sample hasn't even begun to set the permissions on the share. A little time is required to put a sample together that you'd (maybe) understand.
|
|
|
|
|
I used to delete the olds posting that tends to be forgotten.
I google a lot and din't find any solution. I understand well the two examples that I had posted but I don't know how to set permission for read-only.
Thank you,
Shay Noy
|
|
|
|
|
Well, this isn't as easy as I thought it was going to be. You can't really use the built in .NET classes on the Share because the Share doesn't have any .NET classes around it yet.
The easiest way to do it, that I've found is to use more WMI stuff to create the access control lists. You can read up on it at We All Scream for Security Descriptors[^].
There's also some VBScript that is generic enough to modify here[^]. It's not very difficult to rewrite this sample into VB.NET, just time consuming.
|
|
|
|
|
I am using the propertygrid for the runtime controls . The problem is i amnot able to put the combobox on the top of the proprtygrid on the right side top which looks like in vs2005 Properties Window.How to put the combobox. and in the combobox i want to show the all thecontrols present on the form like in vs2005 properties Window.
Waiting For Response...
D.V.Sriram
|
|
|
|
|
You don't put it on or in the PropertyGrid, you put it above the PG. Then you populate it with your control names, or whatever, handle it's SelectedValueChanged event, then bind the PG the control selected by the ComboBox.
|
|
|
|
|
Thanks For Replying.....
I am using this code
Private Sub Properties_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim al As New ArrayList
For Each ctr As Control In whitepage.Controls
ComboBox1.Items.Add(ctr)
MessageBox.Show(ctr.ToString())
Next
End Sub
If i use like this , I am getting the panel ,Toolstip properties on the properties toolbox , But i am not able to see these instances on the properties toolbox . I created a form Properties in that i added ComboxBox1,PropertiesGrid1 and i am showing when i clicked on properties menuitem of popup menu . And i am not able to see the controls that are present on Panel like button1,button2 and runtime generated controls .How to get those instances ?? And how to set the dock for this form on my form ?? Any Idea Help me Out of this ..........
DVSRIRAM
|
|
|
|
|
dvsriram wrote: Private Sub Properties_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim al As New ArrayList
For Each ctr As Control In whitepage.Controls
ComboBox1.Items.Add(ctr)
MessageBox.Show(ctr.ToString())
Next
End Sub
This is because you only added the top level controls contained by whatever whitepage is. You didn't enumerate throught the child controls of each control.
Private Sub AddControlsToPropertyCombo(ByVal container As Control)
' Enumerate the controls in the root container
For Each ctr As Control In container.Controls
' adding each to the ComboBox
ComboBox1.Items.Add(ctr)
' If this control has child controls
If ctr.HasChildren Then
' Call this sub again using this control as the new parent container
AddControlsToPropertyCombo(ctr)
End If
Next
|
|
|
|
|
Hiii
When i am using this code i am getting the controls in to combo box but it is not showing the names of those instance and by showing the properties of those instances in propertygrid . If it shows names by ctr.name then it is not showing their properties in the propertygrid . This is the problem i am getting .
Help me out ...
DVSRIRAM
|
|
|
|
|
OK. I see what you're getting at. The solution is pretty simple - wrap each control in a class that exposes the control and the anme of the control. Watch:
Public Class ControlData
Private _control As Control
Public ReadOnly Property Control() As Control
Get
Return _control
End Get
End Property
Public ReadOnly Property Name() As String
Get
Return _control.Name
End Get
End Property
Public Sub New(ByVal control As Control)
_control = control
End Sub
Public Overrides Function ToString() As String
Return String.Format("{0} : {1}", _control.GetType.FullName, _control.Name)
End Function
End Class
All this does is create a wrapper for a Control that exposes the name of the control it wraps and the control itself. There's an override of the ToString method just to make the text version of this look pretty.
When you add the controls to the ComboBox, you do something like this:
Private Sub PopulateControlsCombo(ByVal parentContainer As Control)
For Each c As Control In Panel1.Controls
' Create a wrapper for the control we found
Dim d As New ControlData(c)
' Add the wrapped control it to the ComboBox. The Add method automatically
' calls the ToString method of whatever object you pass into it.
ComboBox1.Items.Add(d)
' If this control has child controls...
If d.Control.HasChildren Then
' Call ourself with the current control as the new parent container.
PopulateControlsCombo(d.Control)
End If
Next
End Sub
When the user selects an item in the ComboBox, the SelectedItem property will return an Object that you have to cast back to a ControlData object, then you can get at the control contained in that wrapper.
Dim d As ControlData = DirectCast(ComboBox1.SelectedItem, ControlData)
PropertyGrid1.SelectedObject = d.Control
|
|
|
|
|
Thanks For Replying ,
I used ur code in my task . I am getting the things well in the propertygrid ,But it is not looking way in vs2005 .But i am very thankful for ur help . if i take a normal textbox1 at design time andi if i assign the propertygrid.selectedobject =label1 it is displaying in order everything .But the code u gave is showing in 2 properties + icons ,If user has to click those icons and then he can see the properties . I want to assign normally .I use like this .
1) But whenever i am right clicking the on the panel--> i get contextmenustrip in that i added properties .If i click i wrote like this
If (ctrl.GetType().ToString() = "System.Windows.Forms.Label") Then<br />
Dim d As ContolData = New ContolData(ctrl)<br />
PropertyGrid1.SelectedObject = d.Control
i am adding the controls to combobox1 when mouse down on the control . i am displaying when the particular runtime control is clicked using the code like this : and showing in both combobox and propertygrid
ComboBox1.SelectedItem = ctrl.name<br />
Dim cd As ContolData = New ContolData(ctrl)<br />
PropertyGrid1.SelectedObject = cd
using this code i can add the controls at only one time .
but it is working for all dynamic controls except for panel or splitter1.panel1 ,it is showing error Object reference not set to an instance of an object. i dont know how to get for panel . Using ur code i can display the controls incombobox but i am not able to display in propertygrid when particular item is selected in combobox1
2) When i am selecting an item in combobox1 . i am not able to get the properties in propertygrid of that particular item i.e, in ComboBox1_SelectedIndexChanged,i am getting error as "Object reference not set to an instance of an object".Bcoz ,if i take it as control it is displaying in propertygrid .
3) Exactly my task which looks like creation of controls in vs2005 (drag drop,everything for properties same) but it is has something more but all these things i have to create on pages like page1 ,page2 ...and save with a name . And i have to set the page1 properties i.e., width and height so that it can appear one like in word doc . A4 (sizes) ,A3
Waiting for ur Reply ......
DVSRIRAM
|
|
|
|
|
dvsriram wrote: But the code u gave is showing in 2 properties + icons ,If user has to click those icons and then he can see the properties . I want to assign normally .I use like this .
I have no idea what this means. When I do it, I get the full public properties. i have no idea what you did, or didn't do to not get the property grid as normal.
dvsriram wrote: If (ctrl.GetType().ToString() = "System.Windows.Forms.Label") Then
Dim d As ContolData = New ContolData(ctrl)
PropertyGrid1.SelectedObject = d.Control
These three lines alone tell me you don't have the experience required to design and write a forms designer. The problem is that hosting the real Visual Studio Forms designer is probably more complex than writing one yourself!
The first line should read
If TypeOf ctrl Is Label Then
after that, you're doing something that isn't even necessary, but I can't tell you what it should be because there is a lack of context. I have no idea what this code is supposed to be doing, nor do I know what the code around it is, so it's impossible for anyone to tell you why you're getting this message.
dvsriram wrote: 2) When i am selecting an item in combobox1 . i am not able to get the properties in propertygrid of that particular item i.e, in ComboBox1_SelectedIndexChanged,i am getting error as "Object reference not set to an instance of an object".Bcoz ,if i take it as control it is displaying in propertygrid .
Without seeing the code in the SelectedIndexChanged event, it's impossible to tell you what's wrong. But the question leads me to believe that you don't understand your own data model.
dvsriram wrote: 3) Exactly my task which looks like creation of controls in vs2005 (drag drop,everything for properties same) but it is has something more but all these things i have to create on pages like page1 ,page2 ...and save with a name . And i have to set the page1 properties i.e., width and height so that it can appear one like in word doc . A4 (sizes) ,A3
Oh God! I'm sorry to say that your inexperience is going to prevent you from doing this. We could go back and forth in the these forums for a year and still not have a working designer. You're trying to run a marathon and you've just barely learned to walk.
The designs I've seen for this would require you to scrap everything you've already done, and start over. The problem with this is that it would take about 5 chapters of a book to explain it. This just can't be spelled out in a few forum posts.
|
|
|
|
|
Thanks For Replying me Immediately ,
Now i got the output as you told , But i will try to get the things in fast manner and in good way of programming .
Just mention me to know the required things in a well formatted manner . Just mention me some nice books or sites. i have to follow to get good programming skills like you . I want to develop my skills. But i try to put effort to do in good way . I want to write MS exam mcts 2.0 (Windows prgrming) . With ur help anybody can do good .Bcoz ur experienced .
Coming to task , I have to do ,there is no chance to do some other things .
I think you can contribute the same Please dont hesitate to give answers . After trying alot in net ,if i am not getting required output i am asking in this forum .
DVSRIRAM
|
|
|
|
|
Hii
How to disable some of the properties showing in propertygrid at runtime of control like Accessibility ,Behaviour,Data .
Regards ,
DVSRIRAM
|
|
|
|
|
You don't. It'll display every public property in whatever class you give it. The only way to hide properties is to create your own version of whatever controls and hide them through attributes and overrides.
This is what I'm talking about. The kind of skills required to build a designer only come from experience. You'll have to read 100's of articles, books, and websites on everything from interfaces, serialization, code generation, data structures, attributes, design patterns, ... But just reading them won't do you any good. You have to build a bunch of applications using and excersizing these techniques to figure out how all this stuff fits together and how to apply it.
Sure, you can read a bunch of books on metallurgy and mechanical engineering, but that doesn't give you the knowledge to design and build a Ferrari, and that's what you're trying to do.
You want a peek at what it takes?? Try reading these: No, scratch that. Try understanding these:
Hosting Windows Forms Designers[^]
Create And Host Custom Designers With The .NET Framework 2.0[^]
I'd seriously think twice about using this code in your own application. If you can't understand the code, you have no hope of supporting it, nor extending it's functionality.
-- modified at 7:47 Thursday 27th September, 2007
|
|
|
|
|
does this code really put the bitmap image into the picturebox
the picturebox is always black after calling its load method
dim btmp as new system.drawing.bitmap("sam bitmap image location")
picturebox1.image=btmp
picturebox1.load
but doesnt work
thanks in advance
phatkin
|
|
|
|
|
The Load method loads an image from the path specified in the ImageLocation property, replacing the image that you put in the Image property.
---
single minded; short sighted; long gone;
|
|
|
|
|
OK,
So I seem to be one of those rare people that actually converts *back* from Mac to PC. But, what the heck, ya gotta make a living, right?
Over in Mac-land I used to enjoy using Applescript as a way to write simple programs that could automate a lot of mundane tasks. Wondering if it's possible to do some of the same stuff on my new PC.
Specifically, is it possible to:
1) Automate Explorer (or Firefox) to browse the web and download weather images so they're on my machine when i wake up in the morning?
2) Create back ups of specific local folders and ftp them to my web server?
Any suggestions on where to start - books/web sites/etc.. appreciated.
Thanks!
|
|
|
|
|
@largeinsd wrote: 1) Automate Explorer (or Firefox) to browse the web and download weather images so they're on my machine when i wake up in the morning?
You don't need a browser application to request files from the web. Use the WebClient class and the DownloadFile method to download images.
@largeinsd wrote: 2) Create back ups of specific local folders and ftp them to my web server?
That depends on how you want the backup. If you just want to copy the files, that's easy using the File class.
Use the WebClient class and the UploadFile method to send the files over ftp.
---
single minded; short sighted; long gone;
|
|
|
|
|