Click here to Skip to main content
15,915,336 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: App fails on restart problem ? Pin
aaj2329-Apr-11 9:07
aaj2329-Apr-11 9:07 
Questionhow i create simple silverlight2.0 application Pin
wasimsharp16-May-08 17:24
wasimsharp16-May-08 17:24 
AnswerRe: how i create simple silverlight2.0 application Pin
Michael Sync19-May-08 17:43
Michael Sync19-May-08 17:43 
AnswerRe: how i create simple silverlight2.0 application Pin
Member 97203321-May-08 0:15
Member 97203321-May-08 0:15 
QuestionHow can i create simple silver light2.0 Application Pin
wasimsharp16-May-08 17:20
wasimsharp16-May-08 17:20 
AnswerRe: How can i create simple silver light2.0 Application Pin
Michael Sync19-May-08 17:41
Michael Sync19-May-08 17:41 
QuestionWpf Listview edit Pin
member2715-May-08 23:54
member2715-May-08 23:54 
AnswerRe: Wpf Listview edit Pin
User 27100916-May-08 0:58
User 27100916-May-08 0:58 
Create a new WPF Application solution and paste the code into it.

Run the application in debug mode.

Edit the grid.

Press the button.

Look in the Visual Studio output window and you'll see your new edited data.

I'm using a class instead of a data row, but the concepts are still the same.

You can look at the data context in the button's click event and see how to find the data.

In you case, Me.ListColor.Items will be a collection of DataRows. Just access the cells in the DataRow

Karl


<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="400">
<Window.Resources>

<DataTemplate x:Key="cellTemplateName">
<TextBox BorderThickness="0" Text="{Binding Path=BankName}" />
</DataTemplate>

<DataTemplate x:Key="cellTemplateAddress">
<TextBox BorderThickness="0" Text="{Binding Path=BankAddress}" />
</DataTemplate>
</Window.Resources>

<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<ListView Name="ListColor" Grid.Row="0" ItemsSource="{Binding}" >

<ListView.View>


<GridView AllowsColumnReorder="true" >
<GridViewColumn DisplayMemberBinding="{Binding Path=BankCode}" Header="Code" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateName}" Header="Name" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateAddress}" Header="Address" Width="100"/>

</GridView>

</ListView.View>
</ListView>

<Button Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnsave_Click" Margin="0,20,0,0" Content="Save" />

</Grid>

</Window>



Class Window1

Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded

Dim obj As New System.Collections.ObjectModel.ObservableCollection(Of CodeNameAddress)

obj.Add(New CodeNameAddress("hello address 1", "name 1", "5"))
obj.Add(New CodeNameAddress("hello address 2", "name 2", "25"))
obj.Add(New CodeNameAddress("hello address 3", "name 3", "95"))

Me.ListColor.DataContext = obj
End Sub

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

For Each obj As CodeNameAddress In Me.ListColor.Items
Debug.WriteLine(obj.BankCode & " " & obj.BankName & " " & obj.BankAddress)
Next
End Sub
End Class


Public Class CodeNameAddress

Private _strBankAddress As String
Private _strBankName As String
Private _strBankCode As String


Public Property BankAddress() As String
Get
Return _strBankAddress
End Get
Set(ByVal Value As String)
_strBankAddress = value
End Set
End Property

Public Property BankName() As String
Get
Return _strBankName
End Get
Set(ByVal Value As String)
_strBankName = value
End Set
End Property

Public Property BankCode() As String
Get
Return _strBankCode
End Get
Set(ByVal Value As String)
_strBankCode = value
End Set
End Property

Public Sub New(ByVal strBankAddress As String, ByVal strBankName As String, ByVal strBankCode As String)

_strBankAddress = strBankAddress
_strBankName = strBankName
_strBankCode = strBankCode

End Sub

End Class

Cheers, Karl

&raquo; CodeProject 2008 MVP
&raquo; Microsoft MVP - Client App Dev

My Blog | Mole's Home Page | MVP Profile

Just a grain of sand on the worlds beaches.

<div class="ForumMod">modified on Friday, May 16, 2008 7:43 AM</div>

-- modified 27-Feb-21 21:01pm.
GeneralRe: Wpf Listview edit Pin
member2717-May-08 2:03
member2717-May-08 2:03 
AnswerRe: Wpf Listview edit Pin
User 27100916-May-08 1:40
User 27100916-May-08 1:40 
Questionto WPF or not Pin
zorro91115-May-08 12:37
zorro91115-May-08 12:37 
AnswerRe: to WPF or not Pin
Ed.Poore15-May-08 12:54
Ed.Poore15-May-08 12:54 
GeneralRe: to WPF or not Pin
zorro91115-May-08 13:01
zorro91115-May-08 13:01 
GeneralRe: to WPF or not Pin
Ed.Poore15-May-08 13:36
Ed.Poore15-May-08 13:36 
GeneralRe: to WPF or not Pin
zorro91115-May-08 13:48
zorro91115-May-08 13:48 
GeneralRe: to WPF or not Pin
Ed.Poore15-May-08 14:10
Ed.Poore15-May-08 14:10 
GeneralRe: to WPF or not Pin
zorro91120-May-08 20:43
zorro91120-May-08 20:43 
GeneralRe: to WPF or not Pin
Ed.Poore20-May-08 22:31
Ed.Poore20-May-08 22:31 
QuestionHELP! Pin
Jammer15-May-08 9:56
Jammer15-May-08 9:56 
QuestionRe: HELP! Pin
Jammer15-May-08 10:21
Jammer15-May-08 10:21 
AnswerRe: HELP! Pin
Jammer15-May-08 11:14
Jammer15-May-08 11:14 
Questionediting the listview in WPF Pin
member2715-May-08 2:12
member2715-May-08 2:12 
AnswerRe: editing the listview in WPF Pin
User 27100915-May-08 6:51
User 27100915-May-08 6:51 
QuestionHow Silverlight write data to XML file? Pin
tomalani15-May-08 1:57
tomalani15-May-08 1:57 
AnswerRe: How Silverlight write data to XML file? Pin
Michael Sync15-May-08 7:29
Michael Sync15-May-08 7:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.