|
I agree, I have to add them to the panel.
Me.PanelL.Controls.Add(newButton)
accomplished this task
|
|
|
|
|
The next part is doing this with a loop. I can create one element and add it to the panel, but how would I create x number of them?
|
|
|
|
|
Looping is easy, the problem I think you'll encounter is not adding more than one label but determining how many too add.
Modifying the code above slightly to demonstrate the loop -
Dim MyLabel As Label 'declare at modular level
'pass the value of the number of labels you'll need to
'the CreateLabels sub
Private Sub CreateLabels(ByVal NumberOfLabels as Integer)
Dim i As Integer
Do Until i = NumberOfLabels
'create a new instance of a label
MyLabel = New Label
'add formatting, positioning, event handlers, etc. here
Me.PanelL.Controls.Add(MyLabel) 'add the label to the panel
i += 1 'increment i so as to avoid an infinite loop
Loop
End Sub
|
|
|
|
|
Hi everyone:
While digging down into the ADO.NET side of VB.NET I came across a nice little bit of code that allows me to return the schema of a database table.
Code snippet:
Private Sub Table_Schema(ByVal strTbl As String)
'Retrieving schema for columns from a single table
Dim cmd As OleDbCommand = New OleDbCommand(strTbl, objConnection)
cmd.CommandType = CommandType.TableDirect
Try
'Retrieve schema only
objConnection.Open()
'Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
'Get references to schema information
Dim SchemaTable As DataTable = reader.GetSchemaTable()
'Close and release the connection before processing results
reader.Close()
objConnection.Close()
'Display schema table column headers
Dim col As DataColumn
SchemaTableList.View = View.Details
SchemaTableList.Clear()
For Each col In SchemaTable.Columns
SchemaTableList.Columns.Add(col.ColumnName, 100, HorizontalAlignment.Left)
Next
'Display Schema
Dim row As DataRow
Dim ColCount As Integer = SchemaTable.Columns.Count
For Each row In SchemaTable.Rows
Dim OrderDetails(ColCount) As String
Dim ColIdx As Integer
For ColIdx = 0 To ColCount - 1
OrderDetails(ColIdx) = Convert.ToString(row(ColIdx))
Next
Dim NewItem As ListViewItem = New ListViewItem(OrderDetails)
SchemaTableList.Items.Add(NewItem)
Next
Catch OleDbExceptionErr As OleDbException
'Display the error
MessageBox.Show(OleDbExceptionErr.Message, "Access SQL")
End Try
End Sub
The problem I have is; I don't need all that schema information. All I'm interested in is the Name of the Column, the datatype of the column and is it a primary column(field) or not.
In VB6 you could determine what information you wanted returned to you. My question is: Is there such a method available in VB.NET/ADO.NET? If so, How do you set it up for use?
Quecumber256
|
|
|
|
|
Hi
I am tryning to make aHi
I’m trying to make a program that prints out some text on a special location on a paper.
I’m using a Windows form, with some textboxes with a sender and resiver address.
Some combo boxes to determine a transport method, I made some text appear in a text box, when I check the combo box.
Example:
I check the box whose label is Taxi, and the word Taxi appears in a text box.
Then I made some buttons for the command printing, and for the command Exit (made a menu strip too, with the same functions).
My question then is how I can print this out.
I want to have the senders address on one location, and the resiver address on another location on the printed paper
And so on....
I’m using VB in visual studio 2005, and I’m going to print this out on a Oki Microline 520.
Ole Kr
A new beginner in VB.net
|
|
|
|
|
There are many ways to do what you ask...
Are you using a database to store information?
If so, it may have reporting features that you could use quite easily.
Would you consider Office automation, e.g. Word, Excel?
If so, you could simply create a Word template or Excel template and insert the data and print it from your code. This would require an installation of one of the above MS Office applications.
You could use Crystal Reports (if you have it).
Otherwise, you will need to work with Printer/Document objects, which could be quite difficult for someone new to VB.
Steve
|
|
|
|
|
Hii all,
I know this may seems to be a silly question but I need to know. Is it possible to delete an Executable file from itself. e.g I have an application, I want to delete its executable file from the code written in it.
Please reply.
Mubashir
|
|
|
|
|
No, you can't. The .EXE file remains locked open so long as the code in it is loaded into a process. You'll have to quit and have an external process delete this .EXE.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
is there a way that you could build an exe file into memory as a separate process and then have it wait for the parent process to die off and then delete it then end and kill itself from memory?
|
|
|
|
|
Well, you can load a new Assembly from an array of bytes, documented here[^]. The bytes can either be sourced from emitted code or from data in a file.
The problem is creating an entirely new Process out of that Assembly. I don't know how you can get from a loaded assembly to a whole new process.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi folks,
I'm in the process of writing an application to check for the existance of files and their sizes to replace a program we have at work which doesn't work (and which the source code has been lost).
Now I've recently started using Visual Basic 2005 Express Edition. I have a little bit of experience of VB6 but I'm struggling to get my head around the way some of the things are done in VB.Net.
The program is a console program which is supposed to sit in the background until a certain time and then start performing commands. I would like to add a couple of forms that can be used while the console application is running.
I found an example of code on a web site (can't remember the source sorry) which shows the form I want but then transfers execution to that form and stops running anything in the console window. The code I have is below...
<br />
Application.Run(New Form1())<br />
Now I would like the form to show on the screen and be active but also have things running in the background. I guess it would be classed as having two tasks running at once.
I'm just wondering if anyone knows how I can acheve this?
The idea is the end user can use things on the form while other tasks run on the console window in the background. At the moment though I can only have the console window doing something OR the form active, not both at the same time.
Sorry if this is a bit vague. I've spent the past hour searching Google but I can't seem to find anything obvious.
Could anyone suggest anything?
Regards,
Rob
|
|
|
|
|
You'd have to launch your forms on their own seperate threads. But, if you're going to use forms, you'd be better off starting from a Windows Forms app and including support for a console, instead of a Console app written trying to do forms.
It's easier to launch the Console portion of your app on it's own thread than it is to launch the Forms portion.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ahh I see. Is it easy to open a console window from a Windows Forms app?
Thanks for the advice. Luckily I haven't got very far yet with the app so I'll start again with a new Windows Forms app.
Regards,
Rob
|
|
|
|
|
Try reading this[^] article for an example.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am written a program in VB.NET 2005 and have used Crystal Reports XI release 2 Developers Edition for reports. All working as expected.
My problem is that when I include the Crystal Reports Merge Modules into my Install Sheild project, package up and the run the MSI on a PC, the installer creates several folders in the root directory contain several files that relate to Crystal Reports.
These folders include html, css, images, js and prompting and seem to relate to some web functionality of Crystal. (Not that I require any web front end to my project).
Surely they should not install to the root folder? Can anyone point out my mistake?
Thanks
Steve Jowett
|
|
|
|
|
i maked visual basic component with a component class i add a texbox and modify some properties a methods and know i wan to know how can i make a .dll from this component because i want to add it to my tool tabs. ????
Mago R. Vasquez (Gbyte)
|
|
|
|
|
Did you build it as part of a windows class library?
If so, locate "Build" on the VS menu bar, click on it & then click on "Build solution". You'll find the dll in the solution bin folder.
|
|
|
|
|
How Can I Get Cpu Name???
|
|
|
|
|
FriendlySoluations wrote: How Can I Get Cpu Name???
Me.Text = System.Environment.MachineName
Hope this helps
clanguage
|
|
|
|
|
I think he mean the name of the actual CPU, not the name of the machine in which the CPU resides.
|
|
|
|
|
Colin Angus Mackay wrote: How Get Cpu Name
You might be right. I never thought about the chip.
clanguage
|
|
|
|
|
WMI... Alway's slow but.. somthing like this..
Imports System.Management
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ConfigNamespace As String = "\\.\root\cimv2"
Dim query As String = "select * from Win32_Processor"
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(ConfigNamespace, query)
Dim collection As ManagementObjectCollection = searcher.Get
For Each item As ManagementObject In collection
For Each prop As PropertyData In item.Properties
Try
Console.WriteLine(prop.Name + ":" + prop.Value.ToString)
Catch gExVar As Exception
End Try
Next
Next
End Sub
|
|
|
|
|
How can i use the project(Windows Application) made by vb.net(use Ado.Net) depend on SQL Server2000 in client pc without install SQL Server2000 in the client pc?
In other words I want ask if there is any way in which we will not install SQL Server2000 on client pc and the program will run properly?
|
|
|
|
|
you just need to change the connection string for the server. So save your connection string in app.config file and use that. or read it from any XML or text file from client machine
|
|
|
|
|
If your application is written dependant on an SQL Server backend, you'll still need an instance of SQL Server running somewhere, either one on the client PC or one on another server. On the local machine, you can install the desktop version of SQL Server. For SQL Server 2000 it's called MS Desktop Engine, or MSDE[^]. For SQL Server 2005, its called SQL Server Express[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|