|
I have an experience on Using VBA list box,
There is a mode for the list box to have a checkbox before the item text.
Does the VB.NET listbox have this function ?
If not ...
Any suggestion to do that?
Thanks~!
|
|
|
|
|
The ListBox control doesn't do this anymore.
Instead, use the CheckedListBox control.
|
|
|
|
|
You could also use ListView amd turn on checkboxes.
Use listview if you also want to change colour of items in the list.
However I had trouble disabling checking items on click, CheckedListBox was easier for that.
|
|
|
|
|
I have create a control for my own use,
There are number of text box, labal, ...
And there is a save button named "btnSave"
When Click the "btnSave"
I would like to show a message to the status bar,
where the status is a control on the Form.
The structure like
Form
+---myControl
| +---label1
| +---label2
| +---textField1
| +---btnSave
| +---etc ...
|
+---StatusBar
|---StatusItem1
How can show the the message to StatusItem1 when I click the btnSave?
for example,
Click "btnSave", the Message is "Hello", which will show in statusItem1.text
Thank YOu!
|
|
|
|
|
StatusBar1.Panels(1).Text = "Hello"
|
|
|
|
|
Hi,
I'm a C# type that just landed a VB.Net assignment and I'm having trouble getting a handle on Sub Main in VB.Net. The folks at the new place don't use Main while all the examples in documentation seem to. Evidently it's optional and not very VB6. Where does control get passed to if there isn't one? Also, every example that I've seen places Main() in a Module, not a Class. Is that important or does it just default it to Public?
Thanks in advance.
|
|
|
|
|
You're right. The Main() function is optional in VB. You can set the app's "startup object" via Project Properties.
1) Go to the Solution Explorer.
2) Right click the project and select Properties.
3) Select CommonProperties\General in the tree.
4) Select the Startup Object and click OK.
(Choose "Sub Main" if you want it to call your Main() function.)
You can place the Main() anywhere you want. In a Module or in a Class. It must be defined as Public and Shared (ie: static), just like how you would do it in C#.
Public Class Main
Public Shared Sub Main(ByVal CmdArgs() As String)
End Sub
End Class
|
|
|
|
|
Hi,
How do i get the maximum number of days in a month using DateTimePicker? and how to display the current Time with a format (ex. 10:00 am)... and how to get the number of days from the first date that i picked until to the last date (ex. From : 01/12/06 To 01/14/06) result 2 days ?
Pls i really need your help... thanks and more power...
Welbert
|
|
|
|
|
welbert wrote: How do i get the maximum number of days in a month
Date.DaysInMonth(theYear, theMonth)
welbert wrote: how to display the current Time with a format (ex. 10:00 am)
Set the following DateTimePicker properties in the designer...
Format = Custom
CustomFormat = h:mm tt
See MSDN for more formatting codes.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandarddatetimeformatstrings.asp[^]
welbert wrote: how to get the number of days from the first date that i picked until to the last date
Get the selected date and time from the picker like this...
Dim myDate As Date = myDateTimePicker.Value
Get the number of days like this...
myDate1.Subtract(myDate2).TotalDays
|
|
|
|
|
Thank you, Joshua.
I have done all, with no compiling and linking error, but still can't see the horizontal scrollbar.
I have a question, in the following statement,
fMax = fMax / Screen.TwipsPerPixelX
what's the relationship between screen.twipsperpixelx and the listbox?
I can only see the vertical scrollbar. How can I see the horizontal scrollbar there?
Joy Anne
|
|
|
|
|
Joy Anne wrote: Thank you, Joshua.
I'm glad I could help.
Just to let you know, you should be replying to my posts in your original thread instead of starting new threads. Otherwise you'll confuse others in this forum and I might miss your new thread. Let's just continue from this thread from now on.
Joy Anne wrote: what's the relationship between screen.twipsperpixelx and the listbox?
VB6's default screen units are twips, not pixels. These units are used to draw things onscreen. They're also used to place controls via Top, Left, Width, and Height properties. The Win32 libraries do everything in pixels. So, we must convert our measurements from twips to pixels before sending them to the Win32 library. In this case, we're sending these measurements via the SendMessage() call.
Joy Anne wrote: I can only see the vertical scrollbar. How can I see the horizontal scrollbar there?
That's odd. Are you calling the UpdateHorizontalScrollbar() method after you've added your strings to the ListBox?
|
|
|
|
|
Yes, I call the UpdateHorizontalScrollbar() method after I've added my strings to the ListBox.
I did debug inside the UpdateHorizontalScrollbar() and found the information there (such as lstCtrl.ListCount, lstCtrl.Style etc.) is correct.
But I can't see the Horizontal scrollbar there. Please have a look the code related to this issue.
Public lstCtrl As ListBox
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
(after I've added my strings to the ListBox)
Set lstCtrl = frmjoy.List3
Call UpdateHorizontalScrollbar
' Analyzes given listbox and displays a horizontal scroll bar if needed.
Public Sub UpdateHorizontalScrollbar()
Dim fMax As Single
Dim fValue As Single
Dim iIndex As Integer
' Get length of longest text in listbox.
fMax = 0
For iIndex = (lstCtrl.ListCount - 1) To 0 Step -1
fValue = lstCtrl.Parent.TextWidth(lstCtrl.List(iIndex))
If (fValue > fMax) Then fMax = fValue
Next
' Convert max text length to pixels.
fMax = fMax / Screen.TwipsPerPixelX
' Increase length for checkboxes and margins (in pixels).
If (1 = lstCtrl.Style) Then fMax = fMax + 13 ' Offset for checkbox.
fMax = fMax + 4 ' Offset for margins.
' Set horizontal scrollbar length.
SendMessage lstCtrl.hwnd, &H194, CLng(fMax) + 1, 0&
End Sub
Joy Anne
|
|
|
|
|
Hmm... the code looks right to me.
Another thing I should mention is that the horizontal scrollbar will not appear if all of the text fits inside the ListBox. It will only appear if the text exceeds the width.
Try giving your ListBox a HUGE string and see what happens.
If it still doesn't work, then as a test, try replacing fMax with 1000 in the SendMessage call. That should force it to appear too.
|
|
|
|
|
Hi,
I need control over a standard TWAIN scanner out of my application, StartScan and some settings, color/sw, resolution ...
Have anybody experience or some idea
Thanks
-- modified at 18:51 Wednesday 18th January, 2006
|
|
|
|
|
Hello guys,
i'm using access 2003 and SQL 7.0
well, via my access program i want to transfer a specific table from SQL to my access database (i mean by a module), so that i can make everything i want. i don't want to use the manual step process, FILE>GET EXTERNAL DATA> and so on ... A module must run the process.
please somebody can help me !!!!
hoping to hear from you guys,
Marc.
Thank you.
-- modified at 14:53 Monday 23rd January, 2006
|
|
|
|
|
Hello everyone,
I have two arraylists, let's call them ParentArrayList and ChildArrayList. I'm converting them into arrays, but I'm having a hard time getting the values out of the ChildArrayList. I'm pretty new to VB.Net (especially how it works with arrays), so hopefully you can help me find what I'm doing wrong with my code.
Here's where I'm adding an element to the ParentArrayList:
For i = 1 To intLimit<br />
ParentArrayList.Add(MakeChild(i))<br />
Next<br />
<br />
ParentArrayList.ToArray()<br />
Response.Write(ParentArrayList(1))
Note: the response.write returns "System.Object[]", so I know casting is probably an issue but I'm not sure exactly sure how to do that besides how I'm doing it in the following:
Function MakeChild(ByVal SomeNumber as Integer)<br />
'cut out some SQL stuff here<br />
<br />
While DataReaderResult.Read() = True<br />
For i = 0 To 4<br />
ChildArray.Add(DataReaderResult(i))<br />
Next<br />
End While<br />
drRes.Close()<br />
<br />
Return ChildArray.ToArray
It may be that I'm using ToArray improperly as I have yet to find a good explanation on its usage. Plus after all that's taken care of I still need to know how to get the information out of an element in Child array.
Any ideas? Thanks in advance for your help!
EDIT: ChildArray.ToArray(Type.GetType("System.String")) now returns System.String[] so I've gotten that far. Now I just need to figure out how to get values out from referencing the ChildArray via the ParentArray (ie something along the lines of Response.Write(ParentArray(1, ChildArray(4))) )
-------------------
abort, retry, fail?
-- modified at 12:13 Wednesday 18th January, 2006
|
|
|
|
|
This line doesn't accomplish anything:
ParentArrayList.ToArray()
Sure, it does create an array, but you throw it away immediately. The method returns the array, so you have to take care of the return value:
ParentArray = ParentArrayList.ToArray()
But why are you turning the list into an array anyway?
Once you put the child array in the parent list, you can access a child array like this:
CType(ParentArrayList(0), String())
(With reservation for syntax errors, I program in C# normally.)
To access the items in the child array, just use an index on the array:
CType(ParentArrayList(0), String())(0)
---
b { font-weight: normal; }
|
|
|
|
|
The .ToArray was pretty much just grasping at straws because of what I thought was a casting error. But, your explanation helped quite a bit and everything's working just great.
Thanks for your help!
-------------------
abort, retry, fail?
|
|
|
|
|
How do you add details in a listview of 2 columns in vb.net. a listView is already created. i need to create a new ListViewItem and add details in the listview from 2 string arrays in the corresponding 2 columns!! Plz Help!! Thanx!!
Devraj Raut!!!
|
|
|
|
|
You can find an example of how to do this right on the first page of the ListView docs[^].
With ListView1
.View = View.Details
.AllowColumnReorder = False
.FullRowSelect = True
.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
End With
Dim myItem As New ListViewItem("something", 0)
myItem.SubItems.Add("column 2 data")
ListView1.Items.Add(myItem)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi;
First rightclick LV and get its properties. in general tab set view to reportview.In columnheaders tab add two columnheaders and add 2 captions for it if you like.
then
Sub Form_load or something else
dim I as integer
Dim lst as listitem
for i=lbound(StringArray1) to ubound(StringArray1)
set lst=listview1.listitems.add(I,,StringArray1(1)) '.Add(Index,Key,text,Icon).You can add a unique key if you like or needed to for each item.
lst.subitems(1)=StringArray(2)
next i
i hope this will work
bye
Kanchana
|
|
|
|
|
When printing a report developed in Crystal Reports in windows application, the application is giving an error : "Invalid printer specified."
misecprj
|
|
|
|
|
It would appear that the printer name you gave doesn't match the name of a printer installed on the machine. But without seeing your code to setup your printing, it's really hard to tell what happened.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to use my own icon on all form of windows application. And I set "Application Icon" of Build item in Common Properties folder of project's Properties with my icon file. Unfortunately when I set the Icon property to my own icon, in Icon property of a window form I can see my icon, but on the form it shows the Solution Explorer's icon file's icon. How can I fix that?
Also when I deploy my application, I set icon for desktop and window Start up's All Program using same icon file. I don't know why on desktop it shows my icon, but on Start up menu it displays vb.net
Solution Explorer's icon file's icon. What cause this problem and is there a way to correct it?
Thanks in advance.
|
|
|
|
|
An icon file can contain different sizes for the same icon, but you have to create these sizes. The system will look in the icon file for the appropriate size image it needs for where the icon is going to be displayed. If the appropriate size is not found in the file, a default icon is used.
Edit the icon file and add images for, say 32x32 and 16x16. Some implementations, like Explorer's Large Icon view in Windows XP, can look for a 64x64 image of your icon.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|