Hi, Prakash.
To get it right, because I don´t use Listviews.
The "item" should be an entry inside the Listview.
The item itself should contain "subitems" ?
Is it possible to use the Checkbox also as a Subitem?
So like this:
items.Subitems.add(chk) ???
and remove the line:
ListView1.Controls.Add(chk)
And if you need 3 checkboxes? (I don´t see three of them.)
Repeat the items.Subitems.add(chk) line with appropriate variablenames.
Maybe with a Loop inside the Readline.Read.
I would try to have only one Item which would contain the checkboxes and the all other stuff that is read out of a "Dataset" (the Data that are bundled to one Set).
So if the
Quote:
ListViewItem
can have Subitems and can have Controls inside of it, I would do all Data placed in Controls.
So like
Quote:
item.SubItems.Add(READER.GetString("name"))
item.SubItems.Add(READER.GetString("room_no"))
Will become for example:
item.Controls.Add(New Lable_xxx.Text = READER.GetString("name")
item.Controls.Add(New Lable_xxy.Text = READER.GetString("room_no")
If You are using WPF or UWP, please try to use Classes and Datatemplates.
Classes are the Data read out of the Reader into Objects.
These should go into an ObservableCollection (that is of Your Classtype)
then the ListView will be bound to this Collection (ItemsSource).
In Xaml the Datatemplate could look like this:
<DataTemplate x:Key="LindenstrasseTemplate"
DataType="local:LindenstrasseWikiPediaEpisode">
<Border BorderBrush="Black"
BorderThickness="2"
CornerRadius="4"
d:DesignHeight="150"
d:DesignWidth="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Label Content="{Binding Titel}"
Margin="4"
FontSize="36"
FontWeight="Bold" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar IsIndeterminate="{Binding Downloading, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.ColumnSpan="2"
Grid.Column="1"
Height="28"
Margin="4,0"
Visibility="{Binding Downloading, Converter={StaticResource BooleanToVisibilityConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Style="{StaticResource OrangeSwitchStyle}"
IsChecked="{Binding DateiVorhanden, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="10,0,4,0"
Grid.Column="0"
HorizontalAlignment="Left" />
<Label Grid.Column="1"
Content="{Binding StaffelFolge, FallbackValue=999}"
Width="Auto" />
<Label Content="{Binding Folge}"
Width="Auto"
Grid.Column="2" />
<Label Content="{Binding Sendedatum}"
HorizontalAlignment="Stretch"
Width="Auto"
Grid.Column="3" />
</Grid>
<Label Grid.Column="0"
Content="{Binding Dateiname}"
Margin="4"
Grid.Row="2" />
</Grid>
</Border>
</DataTemplate>
The Listbox is my Example, but you can use the ListViewControl, and set the
ItemsSource to the ObservableCollection, and also set the
ItemTemplate, that the ListView can render the ListViewItems acoordingly.
("The SelectedItem to a Variable/Property to get all Information of the Selected (Dataset)" Only if You are using MVVM)
<ListBox x:Name="LBLindenstrasse"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
AlternationCount="3"
Grid.Column="0"
ItemsSource="{Binding LindenstrasseListe.DieEpisoden, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource LindenstrasseTemplate}"
HorizontalContentAlignment="Stretch"
SelectedItem="{Binding LindenstrasseAusgewählteEpisode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsSynchronizedWithCurrentItem="True"
Background="#3F7742B5"
Grid.Row="1">
Please ask more about DataTemplates if needed.
c.u. Zui from Hamburg, who never used a ListView (hmm, maybe i should try one, sometime...)