|
-
Aug 8th, 2009, 11:10 PM
#1
Thread Starter
Member
Listview won't show results
Hello guys, I am trying to bind a dataset to the list view. I have included a gridview inside it in order to do that. I try to setup the column headers and the displaymemberbindings at runtime. I get no errors but no data is showing. Any help would be greatly appreciated.
Thanks in advance
Samv12
Code:
Dim x As New GridViewColumnCollection
Dim int As Integer
For int = 0 To ds.Tables(0).Columns.Count - 1 Step 1
Dim y As New GridViewColumn
y.Header = ds.Tables(0).Columns(int).ColumnName
y.DisplayMemberBinding = New Binding(ds.Tables(0).Columns(int).ColumnName)
x.Add(y)
Next
GridView.SetColumnCollection(Gridview1, x)
results.View = Gridview1
results.DataContext = ds.Tables(0).DefaultView
-
Aug 11th, 2009, 06:44 PM
#2
Re: Listview won't show results
Any reason why you are doing that at runtime? I find it easier to just use the DisplayMemberBinding attribute in XAML and then you dont need to do any loops like that in code.
As for why its not working, have you had a look at the "Immediate Window" in Visual Studio when your app is running because that often tells you why a binding has failed (failed bindings are designed not to throw exceptions)
-
Aug 11th, 2009, 06:58 PM
#3
Re: Listview won't show results
Time out...
Listview or GridView? They are NOT the same thing...
-tg
-
Aug 11th, 2009, 07:06 PM
#4
Thread Starter
Member
Re: Listview won't show results
 Originally Posted by chris128
Any reason why you are doing that at runtime? I find it easier to just use the DisplayMemberBinding attribute in XAML and then you dont need to do any loops like that in code.
As for why its not working, have you had a look at the "Immediate Window" in Visual Studio when your app is running because that often tells you why a binding has failed (failed bindings are designed not to throw exceptions)
oh didn't know that man will look into it. The thing is the listview is supposed to be dynamic, so the columns will vary depending upon the situation, so hard coding it in the xaml is not an option for me. Hope am making sense.
-
Aug 11th, 2009, 07:09 PM
#5
Thread Starter
Member
Re: Listview won't show results
 Originally Posted by techgnome
Time out...
Listview or GridView? They are NOT the same thing...
-tg
Your right man. am a newbie to xaml but this is my code:
Code:
<ListView Margin="6,326,76,0" Name="results" Visibility="Hidden" Height="113" VerticalAlignment="Top" HorizontalAlignment="Left" Width="232" ItemsSource="{Binding Path=Table}" >
<ListView.Background>
<LinearGradientBrush>
<GradientStop Color="Gray" Offset="0"/>
</LinearGradientBrush>
</ListView.Background>
<ListView.View>
<GridView x:Name="Gridview1">
</GridView>
</ListView.View>
</ListView>
So its basically a gridview inside a listview in order to have columns, as i think the listview only has item properties.
-
Aug 11th, 2009, 07:22 PM
#6
Re: Listview won't show results
 Originally Posted by techgnome
Time out...
Listview or GridView? They are NOT the same thing...
-tg
Not in winforms no, but a ListView in WPF can house a GridView element inside it's View property to make it look like a datagrid (just as the OP has shown in his example XAML in the post above this one)
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
|