Byterat Prabhata
Top achievements
Rank 1
Byterat Prabhata
asked on 04 May 2010, 12:02 PM
Private Sub rgv_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles rgv.Click
'
' Retrieve data to variable
'
dsId = rgv.CurrentRow.Cells("idRoute").Value.ToString
dsDepart = rgv.CurrentRow.Cells("city1").Value.ToString
dsArrival = rgv.CurrentRow.Cells("city2").Value.ToString
'dsStatus = rgv.CurrentRow.Cells("status").Value.ToString
'
' Set TextBox
'
tKode.Text = Format(Val(dsId), "00000")
cbCity1.Text = dsDepart
cbCity2.Text = dsArrival
End Sub
Codes above works well on WindowsForms. My question is how to achieve same scenario with WPF?
I just want get some value(s) from grid to textbox based on column name as string.
Thanks.
'
' Retrieve data to variable
'
dsId = rgv.CurrentRow.Cells("idRoute").Value.ToString
dsDepart = rgv.CurrentRow.Cells("city1").Value.ToString
dsArrival = rgv.CurrentRow.Cells("city2").Value.ToString
'dsStatus = rgv.CurrentRow.Cells("status").Value.ToString
'
' Set TextBox
'
tKode.Text = Format(Val(dsId), "00000")
cbCity1.Text = dsDepart
cbCity2.Text = dsArrival
End Sub
Codes above works well on WindowsForms. My question is how to achieve same scenario with WPF?
I just want get some value(s) from grid to textbox based on column name as string.
Thanks.
5 Answers, 1 is accepted
0
Hi,
You can use CurrentItem property. Just cast it to your object type and get desired property value.
Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You can use CurrentItem property. Just cast it to your object type and get desired property value.
Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Byterat Prabhata
Top achievements
Rank 1
answered on 04 May 2010, 01:00 PM
tKode.Value = rgv.CurrentItem.ToString ' tKode.Value is : System.Data.DataRow
tKode.Value = rgv.SelectedItems(0).ToString ' tKode.Value is empty
rgv.SelectedItem = (DirectCast(Me.rgv.ItemsSource, String).ToString)
tKode.Value = rgv.SelectedItem.ToString ' does not work
tKode.Value = rgv.CurrentCell.ToString 'tKode.Value is empty
Is there sample code?
tKode.Value = rgv.SelectedItems(0).ToString ' tKode.Value is empty
rgv.SelectedItem = (DirectCast(Me.rgv.ItemsSource, String).ToString)
tKode.Value = rgv.SelectedItem.ToString ' does not work
tKode.Value = rgv.CurrentCell.ToString 'tKode.Value is empty
Is there sample code?
0
Byterat Prabhata
Top achievements
Rank 1
answered on 07 May 2010, 02:37 PM
Let me simplify the question.
I do this code in Windows Form Application and run smoothly as needed:
Now, i need do same thing in WPF Application. But, how??
Dim varCity As String = ???
Code please. I'm frustrated and stuck here.
0
Hi Byterat Prabhata,
You may achieve the desired result in the following way:
The second possibility (but not a preferred one) is to use the elements of the UI as:
Cell[4] specifies the cell whose content you want to work with.
Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You may achieve the desired result in the following way:
Dim currentRow = TryCast(Me.myGrid.CurrentItem, dataRow)
Dim city = currentRow("varTableFieldName")
The second possibility (but not a preferred one) is to use the elements of the UI as:
Dim row = TryCast(Me.myGrid.ItemsContainerGenerator.ContainerFromItem(Me.myGrid.CurrentItem), GridViewRow)
Dim cellValue = row.Cell[4].Value.ToString();
Cell[4] specifies the cell whose content you want to work with.
Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Byterat Prabhata
Top achievements
Rank 1
answered on 12 May 2010, 08:53 AM
Thanks for respond. But i still don't get it.
Recently i use WindowsFormsHost to hold Windows Form Application's form. So i can get busy with another part.
Here sample application what i need. Hope help.
Sample Apps
Recently i use WindowsFormsHost to hold Windows Form Application's form. So i can get busy with another part.
Here sample application what i need. Hope help.
Sample Apps