|
On the DriveList control when you select a drive there is an icon telling you what kind of drive you selected. For example: I select the C: drive then the icon for a hard drive. Another for a floppy, removable drives, and so on.
I want to place the icon of the drive selected on the root node of a treeview. Is there a way to read the icon and us it as an image on the treeview?
Thank you,
Quecumber256
|
|
|
|
|
No, you can't get the icons out of the DriveList control, which, BTW, is not a .NET control.
You CAN however build your own. All you need to do is get the icons out of Shell32 (you already asked about this) and either save them as *.ico files or use some other icons that you want. You use that GetDriveType(?) function that you already know about to get the, well, type of drive that each letter is, then you can set your own icons in your TreeView.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave,
I stumbled on how to do this. I have a third party software called IconForge that will allow you to aquire icons from various .DLLs. I'm aquiring them through the Shell32.DLL. I have extracted about 14 of them and using IconForge converted them into 24 and 32 bit icons.
If you are interested here is what I stumpled on. I have modified it for my specific needs.
Private Sub drvSource_Change()
Dim nodX As Node
Dim fs As Object, drv As Object
Dim drvLtr As String
tvwSource.Nodes.Clear
Set fs = CreateObject("Scripting.FileSystemObject")
Set drv = fs.getdrive(fs.GetDriveName(drvSource.Drive))
drvLtr = drv.DriveLetter
Select Case drv.DriveType
Case 0
'Unknown
Case 1
'Removable
If UCase(drvLtr) = "A" Or UCase(drvLtr) = "B" Then
'Floppy drive
Set nodX = tvwSource.Nodes.Add(, , "r", drvSource.Drive, 1, 1)
Else
Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, 4, 4)
End If
Case 2
'Fixed
Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, 2, 2)
Case 3
'Network
Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, 3, 3)
Case 4
'CD-ROM"
Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, 5, 5)
Case 5
'RAM Disk"
Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, 6, 6)
End Select
'Set nodX = tvwSource.Nodes.Add(, tvwChild, "r", drvSource.Drive, drvSource.ListIndex, drvSource.ListIndex)
tvwSource.LineStyle = tvwRootLines
'nodX.EnsureVisible
End Sub
Thank you
Quecumber256
|
|
|
|
|
Great!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am in need of creating a custom control. What I need is to be able to create a listbox that is larger than the default, for use in a touch screen application. The easiest way to create custom controls is to override the base class of the control you want to create. I see several limitations of applying the mentioned technique for my control, seeing how I must overide the entire rendering and input capture of the entire control.
Can I use the described technique or do I just need to create a new control from scratch?
Kevin
|
|
|
|
|
You don't have to redo the entire control, just the drawing part. The ListBox class exposes properties and events that you supply the code for to custom draw the listbox. Check this[^] out for an example.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a MainForm (MDIParent), a ChildA form and a Child1OfChildA Form. I have a Panel control on ChildA Form, How can i place Child1OfChildA on this panel controll on ChildA from? and how can i show it with a tab control?
Thanks
|
|
|
|
|
A couple of things...
First, you can't add an MDIChild form to another control. It'll only work inside an MDIParent form, in its MDIClient control, which is hidden, but plainly obvious on your MDIParent form. THe MDIClient control is docked to take up the entire unused area of an MDIParent form. You can get a reference to the MDIClient control in the MDIParent form using:
Dim mdiClient As MDIClient
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is MDIClient Then
mdiClient = ctrl
Exit For
End If
Next
If mdiClient Is Nothing Then
Throw New Exception("MDIClient control not found!")
End If
Don't get any cute ideas, there can only be one MDIClient control on a form. You can get more information on it here[^], but it's not very well documented. Also, Windows does NOT support a window being both an MDIParent AND an MDIChild, so you can NOT create a form that is both and nest as many MDIChild forms as you want inside each other.
You CAN, however, treat a form as a control! Ever notice that the Form class inherits from the Control class? Well, in .NET 1.0 and 1.1, it inherits from Control. In .NET 2.0 it inherits from ContainerControl, which eventually inherits from Control, and so does any Windows Forms control, like Button or Label or TextBox. Hmmmm... How could you get a Form to behave like any other Control?
It's not as simple as adding it to another forms Controls collection, but it's very close! Click here[^] for the answer.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 16:14 Wednesday 15th February, 2006
|
|
|
|
|
RageInTheMachine9532
Thank you for your response, i really appriceate it and thank you for the links.
|
|
|
|
|
In my Reports I use ListViewControl. I wantto fill Listview Asynchronly,and use all of its properties , how could i do this?
:-> ^);P;)
'Delegate Sub AddItemsDelegate(ByVal Item As ListViewItem)
'Private Sub AddItems(ByVal Item As ListViewItem)
' If lvCekler.InvokeRequired Then
' Dim d As New AddItemsDelegate(AddressOf AddItems)
' Me.Invoke(d, Item)
' Else
' lvCekler.Items.Add(Item)
' End If
'End Sub
|
|
|
|
|
Hi.
I've a form with 12 TextBoxes. It names are:
pred1
pred2
...
pred12
How can I add counter number to Names in For...Next cycle?
( for i=1 to 12
something=pred {<- i} (?)
next i)
Best regards,
Konstantin
|
|
|
|
|
have you ever heard CONTROLS Collection ?
|
|
|
|
|
...yeah. so what?
i'm writing macros in excel. is it possible to use it there?
Best regards,
Konstantin
-- modified at 9:47 Wednesday 15th February, 2006
|
|
|
|
|
all textboxes are in PANEL named pnlTextBoxes
dim txt as Syetm.Windows.Forms.Textbox<br />
For each txt in pnlTextBoxes.controls<br />
SomeThing=txt.AnyPropery<br />
Next
|
|
|
|
|
In VBA there is no a lot of objects.....such as pnlTextBoxes, controls and other...
Best regards,
Konstantin
|
|
|
|
|
Hi all,
We want to start a VB6 windows app from a windows service in VB.NET 2003. After installing the windows service, it starts the app as a "process" (we can see it in the task manager) and we cannot see the form, so we couldn´t inertact with it.
How we can make to start normally this window app?
Thanks in advance...
Time flies like an arrow
-- modified at 9:57 Wednesday 15th February, 2006
|
|
|
|
|
The service which starts the app has to have the "allow interact with desktop" flag set in order to be able to propagate this to any application started by it and in order to show up with a form or sth similar.
The other method would be to you start the application in the context of a user instead of the system, which has the benefit that the program does not run in the system context (with even more that administrative rights) but only in the limited user context.
All Settings to be made in Administrative Tools/Computer Management/Services.
|
|
|
|
|
thanks!!!!
-- modified at 15:39 Wednesday 15th February, 2006
|
|
|
|
|
I'll say this one more time, because no matter how many times you ask the question, the answer doesn't change!
It's a CUSTOM BUTTON implementation! You can find such an example right here[^]!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave is right.
The standard button control won't show an icon when FlatStyle=System.
Your only choices are to:
A) Change FlatStyle back to Standard.
B) Use a custom button control, like the one Dave linked to.
|
|
|
|
|
I need to retvieve report from 2 tables which have same values in field of one
table. 2 of the tables dont have primary key.I need to retrieve depending on month. plz help me(In cystal reports using vb.net)
|
|
|
|
|
I have a number of experience on using 2 dimension array in VB.NET,
I would like to know some better, and standard pattern to write it.
for an example,
We need to pass a set of patient record from a modules to a form,
this record include all the current male patients(no fixed length).
the record includes (name, sex, age)
Please give me advise and write down your coding style in this issue.
Thanks!!
|
|
|
|
|
I wouldn't use arrays at all.
Make a class with the properties for a patient. Create objects from the class and put the objects in a list, for an example an ArrayList.
---
b { font-weight: normal; }
|
|
|
|
|
I'll second the other reply and extend it a bit.
1) Create a Patient Class including all the attributes for the patient (name, gender, age, et al.)
2) Create a PatientCollection class, inheriting from CollectionBase (see Walkthroughs in help for
details on how to do this)
The Patient class is a gimme. It is pretty much a canonical example of a class/object to be used in a program.
The PatientCollection is a bit more work than the ArrayList but is safer and since you have Option Strict turned on (hint, hint) it will save some casting in your code.
hth
Alan.
|
|
|
|
|
How can I auto-populate two MS Word document fields (customer name) and (address)
From the Northwind database
Example:
MS Word Document: New customer Information
This is to inform you Mr. _________(customer name) has a new address of _______ (address)
Here is my scenario:
User logs in to web page and updates a record for the customer’s new address, which will be stored in the customers table of the Northwind database. User wants to print the above word document: New Customer Information which will contain the updated data
I have visual studio 2003, and Visual studio tools for office
|
|
|
|
|