|
Hello All,
I don't know if this has been done or not so again please tolerate my ignorance.
I'm retriving information from a database and placing the output into selected columns on a listview control. What I would like to do is adjust the columns to the width of the largest data piece in that field.
We can use the Length function to return the number of characters in a field, but I need to convert the string length into twips. For example if a 12 point font's character is 15 twips long then to adjust the listview's column I would multiply 15 by the length of the string and reset the columns width.
Any way of doing this?
Thank you,
Quecumber256
|
|
|
|
|
Quecumber256 wrote: What I would like to do is adjust the columns to the width of the largest data piece in that field.
The ListView control can actually do this for you, but VB6 doesn't provide an easy function to make this happen. You have to make a call to the win32 API.
The following code will resize a ListView column to just fit its text. You need to call this function for every column you want to resize.
Private Declare Function SendMessage Lib "USER32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'
' Re-sizes ListView column so that all of its text is shown.
' If last column is specified, then it is stretched to right side of control.
Private Sub AutoSizeColumn(ctrl As ListView, iColumn As Integer)
SendMessage ctrl.hWnd, &H101E, iColumn, ByVal -2
End Sub
-- modified at 18:36 Monday 30th January, 2006
|
|
|
|
|
Thank you. This worked just as I wanted it too.
Quecumber256
|
|
|
|
|
Hi All,
I am binding a DataGrid to an ArrayList, but in the Grid, it does not show the append row, the one with the asterisk, like it does when binding to a Table or a DataView.
Is there any way to have the grid show the append row when using an ArrayList or Array?
The approach I am exploring right now, is using a class that inherits ArrayList, but cannot figure out which properties it should have, to enable the desired behavior.
Anyone have an idea about this?
Many thanks!
Hiske
|
|
|
|
|
Hello,
I created the class "document":
Public Class Document
Private Shared _title As String
Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
If _title = value Then
Return
End If
_title = value
End Set
End Property
End Class
To set the property value I am using:
Dim MyDocument As New Document
MyDocument.Title = "My book title"
I need to be able to create "second level" properties. An example:
MyDocument.Author.Name = "Author Name"
Instead of having
MyDocument.AuthorName = "Author Name"
I inserted the class "Author", with property "Name" inside Class Document.
It is not working. Could someone explain me how to create it?
Thank You,
Miguel
|
|
|
|
|
shapper wrote: I inserted the class "Author", with property "Name" inside Class Document.
Don't do that. Put the author class in a file of its own. There are very few good reasons to create an inner class and I doubt this is one of them.
shapper wrote: It is not working. Could someone explain me how to create it?
Define "it is not working"! What doesn't it do?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
shapper wrote: Private Shared _title As String
Are you sure _title has to be shared (and Title not)?
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
It sounds to me like you inserted a class definition, instead of an instance of a class. If you have a class called Author, then you can create a property of type Author, also called Author ( or name it whatever you want ) and it will work as you are hoping.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello!
I think something is new in visual studio 2005. Here is the scenerio:
I have a tabcontrol with two tab pages. I have placed one label in 1st tab page and set its visibility to true. When I shift to 2nd tab page the label's visibility has treated as invisible by the compiler at run time.
Is that true? if it is not how could I reach the visible attribute's value while I perform a task in the second tab page rather than defining the following statement
if label1.visible = true then
because it is not working out even though the label1 in visible in 1st tab page.
If you enlight me about it, I would really appreciate it...
Bedri
|
|
|
|
|
B Journey wrote: I have placed one label in 1st tab page and set its visibility to true. When I shift to 2nd tab page the label's visibility has treated as invisible
Ummm...No, it isn't. It's Visible property is still True, the thign is you changed the page that the control is sitting on! It's just like pages in a book. If you change the selected tab, you turn the page. Stuff that's on the previous page is no longer visible.
You're explanation of what you want to do needs more clarification. I can't figure why you're trying to get the Visible property of your label.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I thought the same as you do Dave but it is not working that way. The label1 is placed on 1st tab page and itss state is visible. However, when i shift from next tab page at runtime (while the code is checking its visibility) it says now the label's state is invisible. I tested this with a message box and I got the state status (Invisible) while I was on the 2nd tab page. I am not sure if it is a bug in the Visual Studio 2005.
But thank you for your help. In the meanwhile, do you know where I can get a sample code for wrting WAB (Windows Address Book) in vb.net?
Bedri
|
|
|
|
|
Damn! Screw up on my part. No, the Visible property reflects the actual state of the control. If some other window obscures the entire control in question, it's Visible property returns False, well, because it's not visible anymore. It's functionality is by design, it's not a bug.
As for the Address Book, I don't know of any example code in VB.NET. But, the documentation for the WAB API is here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey folks. I'm faily new to VB2005 and I was wondering if theres a way to have a second form display in the same window as the first (root) form appears
I know you can display a second form in a seperate window by using
my.forms.form2.showDialog()
Thats OK but I would like to have, if possible, the form show in the window that is already open.
any help would be appreciated
Thanks
Microsofts like the dentist you really dread going to them but eventually your forced to.
|
|
|
|
|
Well, if you'll notice, the Form class derives from Control. Since all the controls you see on the form derive from, obviously, Control, Form should be able to be used just like a control. You can't make it appear using ShowDialog, but you can treat it just like any other control.
See this[^] little article on MSDN for more information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Does anybody know how to correctly use the GetUserObjectInformation in VB.Net. I seem to have many problems trying to get it to work. Here is what I am basically trying to do. I want to get the current desktop name. So in order to do so I have to call GetThreadDesktop(GetCurrentThreadId()). Which would go into the handle part of the GetUserObjectInformation call. But for some reason with everything filled in I get an error 0. I have seen this done many times in C++ and C# but have not found any reference in VB.Net.
Thanks,
Jason
|
|
|
|
|
|
Is your API declare like this?:
Private Declare Function GetSystemMenu Lib "user32" _<br />
(ByVal hWnd As Long, _<br />
ByVal bRevert As Long) As Long
Eric Dahlvang-Programmer
|
|
|
|
|
Ah! The declare had hwnd as an integer. I used Long like you said and it works great now!
thanks,
sb
|
|
|
|
|
The correct declaration should be:
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hWnd As IntPtr, ByVal bRevert As Integer) As IntPtr
Handles should always be declared IntPtrs because, just like handles, they're going to be the width of the processor, 32-bit on 32-bit procs and 64-bits wide on 64-bit procs.
The declaration you used, using Long , is a VB6 declaration. In VB6, Long are 32-bit signed integers. In VB.NET, they're 64-bit signed integers. The two representations are NOT compatible with each other!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Good Point
(pun intended)
Eric Dahlvang-Programmer
|
|
|
|
|
hellow to all
i am using Crystal Reports , to view and prints reports ..
i wanna generate a report from SQL Statement automatically , with out going throw the wizard and building column column ,
i wanna take an sql statement with various parameters and show the data in a crystal report ...
how can i build it ?
thxx for any help ..
|
|
|
|
|
Hi all,
I'd like to convert an integer to a formatted string that would be filled with "0" until a certain numbers of characters. For example: if the integer value is 10 and the formatted string has to have a length of 6 characters then the final string it would be "000010". Is there any VB6 function to do that?
Thanks in advance,
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Format$(10,"0000000")
Eric Dahlvang-Programmer
|
|
|
|
|
Thanks a lot !!
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
How can I call a word macro when the document is loaded? (I cannot save it in the document)
I tried with command line param but then it tried to run the macro before the document is loaded. Also saved it in the normal.dot template but I don't have a trigger to call it
Dani
|
|
|
|