I have a form which has a ListView control named ListView1 added at design
time. When I add items using the following code, they don't appear in the
list view. However, if I create a ListView control in code and add it to the
form, it works. Why don't the items show up in the ListView that I added at
desgn time.
' Create three items and three sets of subitems for each item.
Dim item1 As New ListViewItem("item1", 0)
' Place a check mark next to the item.
item1.Checked = True
item1.SubItems.Add("1")
item1.SubItems.Add("2")
item1.SubItems.Add("3")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As New ListViewItem("item3", 0)
' Place a check mark next to the item.
item3.Checked = True
item3.SubItems.Add("7")
item3.SubItems.Add("8")
item3.SubItems.Add("9")
' Create columns for the items and subitems.
ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView.
ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
--
Dennis in Houston 12 3073
Thanks. I feel like an idiot. I have no idea why I had the -2 in the .Add
method.
I was mainly following the example for the ListView control in the MSDN as
follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It
seemed to work ok if I created the control in code rather than at Design Time.
"Q" wrote: Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
I added a ListView1 at design and added your code, seemed to work fine.
I also added...
ListView1.View = View.Details
ListView1.CheckBoxes = True
Greg
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Does this help? http://tinyurl.com/3z7ev
Greg
"Q" <Q@nomail.be> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Hello Dennis,
try to change the column width to a positive figur (eg 100)
If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to
the form, it works. Why don't the items show up in the ListView that I added
at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Thanks. I feel like an idiot. I have no idea why I had the -2 in the .Add
method.
I was mainly following the example for the ListView control in the MSDN as
follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It
seemed to work ok if I created the control in code rather than at Design Time.
"Q" wrote: Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Does this help? http://tinyurl.com/3z7ev
Greg
"Q" <Q@nomail.be> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Hey Dennis,
it seems that the values -1 and -2 can be used.
-1 : autosize to the largest subitem
-2 : autosize to the size of the text of the column header
I have tried both -1 and -2 and they only seem to be working with a listview
created during runtime.
If you use a listview that has been created at design time, these two
settings do not seem to work.
I have no idea why they don't work!
Regards,
Q
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com... Thanks. I feel like an idiot. I have no idea why I had the -2 in the
..Add method.
I was mainly following the example for the ListView control in the MSDN as follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It seemed to work ok if I created the control in code rather than at Design
Time. "Q" wrote:
Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at
design time. When I add items using the following code, they don't appear in
the list view. However, if I create a ListView control in code and add it
to the form, it works. Why don't the items show up in the ListView that I
added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2,
HorizontalAlignment.Center) 'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2,
item3}) -- Dennis in Houston
Hey Dennis,
it seems that the values -1 and -2 can be used.
-1 : autosize to the largest subitem
-2 : autosize to the size of the text of the column header
I have tried both -1 and -2 and they only seem to be working with a listview
created during runtime.
If you use a listview that has been created at design time, these two
settings do not seem to work.
I have no idea why they don't work!
Regards,
Q
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com... Thanks. I feel like an idiot. I have no idea why I had the -2 in the
..Add method.
I was mainly following the example for the ListView control in the MSDN as follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It seemed to work ok if I created the control in code rather than at Design
Time. "Q" wrote:
Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at
design time. When I add items using the following code, they don't appear in
the list view. However, if I create a ListView control in code and add it
to the form, it works. Why don't the items show up in the ListView that I
added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2,
HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2,
HorizontalAlignment.Center) 'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2,
item3}) -- Dennis in Houston
It would appear that when you set the column width in design mode there are
no items added yet (must be the order they are added in
InitializeComponent), so the autosize doesn't know what to do.
Try setting up the columns in design mode, but add the items in code. Then
reset the column width to -1 or -2. Seems to work for me.
Dim item1 As New ListViewItem("item1", 0)
' Place a check mark next to the item.
item1.Checked = True
item1.SubItems.Add("1")
item1.SubItems.Add("2")
item1.SubItems.Add("3")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As New ListViewItem("item3", 0)
' Place a check mark next to the item.
item3.Checked = True
item3.SubItems.Add("7")
item3.SubItems.Add("8")
item3.SubItems.Add("9")
'Add the items to the ListView.
ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
For Each col As ColumnHeader In ListView1.Columns
col.Width = -1
Next col
Greg
"Q" <Q@nomail.be> wrote in message
news:u9*************@TK2MSFTNGP12.phx.gbl... Hey Dennis,
it seems that the values -1 and -2 can be used. -1 : autosize to the largest subitem -2 : autosize to the size of the text of the column header
I have tried both -1 and -2 and they only seem to be working with a listview created during runtime. If you use a listview that has been created at design time, these two settings do not seem to work.
I have no idea why they don't work!
Regards,
Q
"Dennis" <De****@discussions.microsoft.com> wrote in message news:35**********************************@microsof t.com... Thanks. I feel like an idiot. I have no idea why I had the -2 in the .Add method.
I was mainly following the example for the ListView control in the MSDN as follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It seemed to work ok if I created the control in code rather than at Design Time. "Q" wrote:
> Hello Dennis, > > try to change the column width to a positive figur (eg 100) > If you do this, the columns will be visible. > > Don't know why but I tried it and it works! > > Regards, > > Q > "Dennis" <De****@discussions.microsoft.com> wrote in message > news:F9**********************************@microsof t.com... > > I have a form which has a ListView control named ListView1 added at design > > time. When I add items using the following code, they don't appear > > in the > > list view. However, if I create a ListView control in code and add > > it to > the > > form, it works. Why don't the items show up in the ListView that I added > at > > desgn time. > > > > ' Create three items and three sets of subitems for each item. > > Dim item1 As New ListViewItem("item1", 0) > > ' Place a check mark next to the item. > > item1.Checked = True > > item1.SubItems.Add("1") > > item1.SubItems.Add("2") > > item1.SubItems.Add("3") > > Dim item2 As New ListViewItem("item2", 1) > > item2.SubItems.Add("4") > > item2.SubItems.Add("5") > > item2.SubItems.Add("6") > > Dim item3 As New ListViewItem("item3", 0) > > ' Place a check mark next to the item. > > item3.Checked = True > > item3.SubItems.Add("7") > > item3.SubItems.Add("8") > > item3.SubItems.Add("9") > > > > ' Create columns for the items and subitems. > > ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center) > > > > 'Add the items to the ListView. > > ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3}) > > > > -- > > Dennis in Houston > > >
It would appear that when you set the column width in design mode there are
no items added yet (must be the order they are added in
InitializeComponent), so the autosize doesn't know what to do.
Try setting up the columns in design mode, but add the items in code. Then
reset the column width to -1 or -2. Seems to work for me.
Dim item1 As New ListViewItem("item1", 0)
' Place a check mark next to the item.
item1.Checked = True
item1.SubItems.Add("1")
item1.SubItems.Add("2")
item1.SubItems.Add("3")
Dim item2 As New ListViewItem("item2", 1)
item2.SubItems.Add("4")
item2.SubItems.Add("5")
item2.SubItems.Add("6")
Dim item3 As New ListViewItem("item3", 0)
' Place a check mark next to the item.
item3.Checked = True
item3.SubItems.Add("7")
item3.SubItems.Add("8")
item3.SubItems.Add("9")
'Add the items to the ListView.
ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
For Each col As ColumnHeader In ListView1.Columns
col.Width = -1
Next col
Greg
"Q" <Q@nomail.be> wrote in message
news:u9*************@TK2MSFTNGP12.phx.gbl... Hey Dennis,
it seems that the values -1 and -2 can be used. -1 : autosize to the largest subitem -2 : autosize to the size of the text of the column header
I have tried both -1 and -2 and they only seem to be working with a listview created during runtime. If you use a listview that has been created at design time, these two settings do not seem to work.
I have no idea why they don't work!
Regards,
Q
"Dennis" <De****@discussions.microsoft.com> wrote in message news:35**********************************@microsof t.com... Thanks. I feel like an idiot. I have no idea why I had the -2 in the .Add method.
I was mainly following the example for the ListView control in the MSDN as follows:
listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
Do you have any idea why Microsoft put a -2 in for the Column Width? It seemed to work ok if I created the control in code rather than at Design Time. "Q" wrote:
> Hello Dennis, > > try to change the column width to a positive figur (eg 100) > If you do this, the columns will be visible. > > Don't know why but I tried it and it works! > > Regards, > > Q > "Dennis" <De****@discussions.microsoft.com> wrote in message > news:F9**********************************@microsof t.com... > > I have a form which has a ListView control named ListView1 added at design > > time. When I add items using the following code, they don't appear > > in the > > list view. However, if I create a ListView control in code and add > > it to > the > > form, it works. Why don't the items show up in the ListView that I added > at > > desgn time. > > > > ' Create three items and three sets of subitems for each item. > > Dim item1 As New ListViewItem("item1", 0) > > ' Place a check mark next to the item. > > item1.Checked = True > > item1.SubItems.Add("1") > > item1.SubItems.Add("2") > > item1.SubItems.Add("3") > > Dim item2 As New ListViewItem("item2", 1) > > item2.SubItems.Add("4") > > item2.SubItems.Add("5") > > item2.SubItems.Add("6") > > Dim item3 As New ListViewItem("item3", 0) > > ' Place a check mark next to the item. > > item3.Checked = True > > item3.SubItems.Add("7") > > item3.SubItems.Add("8") > > item3.SubItems.Add("9") > > > > ' Create columns for the items and subitems. > > ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) > > ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center) > > > > 'Add the items to the ListView. > > ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3}) > > > > -- > > Dennis in Houston > > >
Thanks to both you an Q for helping. I ddin't read in the documentation
about the -1 and -2 but it seems really strange that Microsoft would do this
instead of adding a properties like autosizeColumnHeaders, etc.
"Greg Burns" wrote: Does this help?
http://tinyurl.com/3z7ev
Greg
"Q" <Q@nomail.be> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
Thanks to both you an Q for helping. I ddin't read in the documentation
about the -1 and -2 but it seems really strange that Microsoft would do this
instead of adding a properties like autosizeColumnHeaders, etc.
"Greg Burns" wrote: Does this help?
http://tinyurl.com/3z7ev
Greg
"Q" <Q@nomail.be> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Hello Dennis,
try to change the column width to a positive figur (eg 100) If you do this, the columns will be visible.
Don't know why but I tried it and it works!
Regards,
Q "Dennis" <De****@discussions.microsoft.com> wrote in message news:F9**********************************@microsof t.com... I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time.
' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9")
' Create columns for the items and subitems. ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)
'Add the items to the ListView. ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
-- Dennis in Houston
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Welie |
last post by:
Hi all-
I am using a listview (MSComctlLib.ListViewCtrl.2)on an Access form.
Actually there are six listviews on the form. I need to do the same
thing to all six forms so I have the loop below....
|
by: Ken |
last post by:
Hi all,
Please help! I'm attempting to apply tooltips to each
individual item in VB.Net's Listview control. In VB6 it
was easy - you just did the following
(assumes "myListView" is the name of...
|
by: BobAchgill |
last post by:
I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The...
|
by: Pucca |
last post by:
How can I tell a mouse right clicks over a listview item that's in a
container panel. I only want to display a popup menu if the user right click
the mouse over an item on the Listview. I don't...
|
by: Michael.Suarez |
last post by:
Is it me, or does it seem like they put no effort into creating the
listview control in .Net.
listview.
A few gripes I have with .Net listview that aren't present in vb6:
-Inability to set...
|
by: garyusenet |
last post by:
I have had no replies to my previous post so perhaps I didn't write it
good enough.
Please excuse new thread but i wanted to break from the last thread
hopefully this thread will be better.
...
|
by: Rob |
last post by:
VS 2005
How can you tell if a value is contained in a specific column (let's say
column 1 named Status) of a ListView ?
In a list box you could go...
If ListBox1.Items.Contains(strWhatever)...
|
by: Mark Olbert |
last post by:
How do I get the DataPager and ListView to play nice together when I use a custom datasource?
In my webpage, I use linq to pull data from a SqlServer database and assign the resulting...
|
by: =?Utf-8?B?SWdvcg==?= |
last post by:
Hi everyone!
I have some strange behavior of ListView control in WPF.
We are developing application in C#.
I created ListView with some items and set SelectedIndex to some index in
the...
|
by: Brian Gaze |
last post by:
I have created a ListView control and have bound this to a datasource.
Within the ItemTemplate of the ListView I have added another ListViewControl
which is databound in the code behind. The idea...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |