Oct 29th, 2009, 10:06 AM
#1
Thread Starter
Member
[RESOLVED] datagrid in vb6
i have a datagrid in form load,
how can i change the columns width and height ?
i want to change with different size each column and not all the same
(with code if you can)
Oct 29th, 2009, 10:14 AM
#2
Re: datagrid in vb6
Something like this?
vb Code:
Private Sub Form_Load()
With DataGrid1
.Columns(0).width = '<~~ your value
.Columns(1).width = '<~~ your value
'~~> and so on...
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
Oct 29th, 2009, 12:23 PM
#3
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
Something like this?
vb Code:
Private Sub Form_Load()
With DataGrid1
.Columns(0).width = '<~~ your value
.Columns(1).width = '<~~ your value
'~~> and so on...
End With
End Sub
DataGrid.Columns(0).Width = "1000"
DataGrid.Columns(1).Width = "2000"
DataGrid.Columns(2).Width = "3000"
i get an error
"subscript out of range "
why?????
Oct 29th, 2009, 12:37 PM
#4
Re: datagrid in vb6
1) Which line gives you the error?
2) How many columns are there in the Grid?
3) Also the value of the width is not a string. It should be
DataGrid.Columns(0).Width = 1000
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
Oct 29th, 2009, 12:42 PM
#5
Thread Starter
Member
Re: datagrid in vb6
in line DataGrid.Columns(2).Width = "3000" i get the error
i have 2 columns , but i want 27 columns as default
i made the change in " " but also the same error
Oct 29th, 2009, 12:43 PM
#6
Re: datagrid in vb6
If you don't have a column, you cannot set a width to it
Create columns in design/runtime and then set the width to it...
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
Oct 29th, 2009, 12:47 PM
#7
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
If you don't have a column, you cannot set a width to it
Either create columns in design/runtime and then set the width to it...
how can i do this ? (create more columns)
Oct 29th, 2009, 12:52 PM
#8
Re: datagrid in vb6
Before I answer that question... What are you storing in Datagrid? Where is the data coming from?
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
Oct 29th, 2009, 01:05 PM
#9
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
Before I answer that question... What are you storing in Datagrid? Where is the data coming from?
i have an adodb connection,recordset
and i have a sub called createdummybase which creates a database
and the fields of that database shows on the datagrid
Oct 29th, 2009, 01:19 PM
#10
Re: datagrid in vb6
Is that an Access database?
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
Oct 29th, 2009, 01:39 PM
#11
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
Is that an Access database?
yeap
Oct 29th, 2009, 01:45 PM
#12
Lively Member
Re: datagrid in vb6
* .ColWidth() requires number, take out the quotes.
* .ColWidth() is in twips. If you want to have column width proportional to the width then write
.ColWidth(2) = .Width * 0.1 ' width of column number 2 is 10% of the width.
Oct 29th, 2009, 01:47 PM
#13
Lively Member
Re: datagrid in vb6
To set number of columns use
.Cols = 10 ' 10 columns, numbered 0..9
Oct 29th, 2009, 01:54 PM
#14
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
kiymik
To set number of columns use
.Cols = 10 ' 10 columns, numbered 0..9
DataGrid.Col exists
DataGrid.Cols does not exists
Oct 29th, 2009, 02:05 PM
#15
Re: datagrid in vb6
Hi I am writing a small tutorial for you on how to use datagrid with access database.... I will upload the same in another hour or so... I am at the office and I need to multitask
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
Oct 29th, 2009, 02:56 PM
#16
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
Hi I am writing a small tutorial for you on how to use datagrid with access database.... I will upload the same in another hour or so... I am at the office and I need to multitask
ok, thanks
where are you going to upload it?
Oct 29th, 2009, 03:31 PM
#17
Re: datagrid in vb6
Here in my next post
Give me another half an hour... just came back from office....
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
Oct 29th, 2009, 04:23 PM
#18
Re: datagrid in vb6
Phew here it is....
Hope this helps....
Attached Files
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
Oct 29th, 2009, 04:44 PM
#19
Thread Starter
Member
Re: datagrid in vb6
Originally Posted by
koolsid
Phew here it is....
Hope this helps....
thank you very much,for your time
you helped me
very good mini tutorial
Oct 29th, 2009, 04:45 PM
#20
Oct 30th, 2009, 08:48 AM
#21
Lively Member
Re: [RESOLVED] datagrid in vb6
Sorry, it was for flexgrid...
Aug 30th, 2017, 09:00 AM
#22
New Member
Re: [RESOLVED] datagrid in vb6
I want to increase or decrease height of my datagrid based on the records from the database. For example, If there are 10 rows then datagrid should set its height exactly to fit 10 rows. Height should not be more than the area covered by rows. I found code for 2005 version but that's not working in VB6. Please help
Aug 30th, 2017, 10:05 AM
#23
Member
Re: datagrid in vb6
Originally Posted by
Siddharth Rout
Phew here it is....
Hope this helps....
Hi Siddharth,
Thanks for precise explanation of Datagrid. I have a question, what is the difference between Data Grid & MS Flex Grid? I mean in which condition should I use a Data Grid & MS Flex Grid?
Thanks,
Dharmesh Joshi
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