|
-
Apr 5th, 2009, 08:31 AM
#1
Thread Starter
Junior Member
[RESOLVED] Enter Text1 to Text 3 in MsFlexgrid vb6
Hello,
I need your help.
In my vb6 Form1, I have 3 Text boxes and a MsFlexgrid1.
Now what I want to do his, when I click on a vb6 button, it will add the text from Text1 to the first column of the MsFlexgrid1, the text2 to the second column and the Text3 to the column 3.
After, each time that I click on that button, it will add a line with the text from the 3 Text boxes.
I can I do that please?
Thanks for your help.
-
Apr 5th, 2009, 08:35 AM
#2
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
Here you go:
Code:
MsFlexGrid1.AddItem Text1.Text & vbTab & Text2.Text & vbTab & Text3.Text
The Tab character (which vbTab contains) is used to separate the columns
-
Apr 5th, 2009, 08:47 AM
#3
Thread Starter
Junior Member
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
Yes, it works.
Just a small problem.
How to auto adjust Msflexgrid column1 width depending on the text in Text1?
-
Apr 5th, 2009, 09:34 AM
#4
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
This is one way to do it... Create a new project and place a commanbutton and a MsFlexgrid... Once you understand the concept, you can apply this to your project...
vb Code:
Private Sub Form_Load() '~~> Declare variables. Dim Entry As String, i As Long MSFlexGrid1.FixedCols = 0 MSFlexGrid1.FixedRows = 0 MSFlexGrid1.Cols = 1 '~~> To add 10 items For i = 1 To 10 Entry = "This is item number : " & i MSFlexGrid1.AddItem Entry Next i End Sub Private Sub Command1_Click() Dim i As Long, maxTwips As Integer, Twips As Integer With Me.MSFlexGrid1 Me.ScaleMode = vbTwips '~~> Loop thru items in the row and find textwidth For i = 0 To .Rows - 1 Twips = Me.TextWidth(.TextMatrix(i, .ColSel)) If Twips > maxTwips Then maxTwips = Twips End If Next i '~~> Reset Width .ColWidth(.ColSel) = maxTwips * Me.MSFlexGrid1.Font.Size _ / Me.Font.Size + 100 End With End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 5th, 2009, 10:27 AM
#5
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
That is valid under the right circumstances, but is not ideal - it only works if the Font for the form and grid are the same (different fonts have different character widths for the same .Size), and it alters the ScaleMode which may cause problems elsewhere.
The "FlexGrid: AutoSize columns" link in my signature contains code which deals with those issues, and allows you to specify other options (such as whether to include the header rows, etc).
-
Apr 5th, 2009, 11:10 AM
#6
Thread Starter
Junior Member
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
Thanks, I will do the test and I'll be back in no time for the verdict.
-
Apr 5th, 2009, 11:16 AM
#7
Thread Starter
Junior Member
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
This his perfect.
Thanks a lot.
-
Apr 5th, 2009, 12:01 PM
#8
Re: Enter Text1 to Text 3 in MsFlexgrid vb6
No problem. 
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|