This is a migrated thread and some comments may be shown as answers.

How to TryCast for GridviewTextbox Editor in Windows form

3 Answers 235 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sakthivel
Top achievements
Rank 1
Sakthivel asked on 28 Feb 2008, 01:28 PM

I am using the windows gridview control.Actualy i want to take a textbox events from gridview textbox column.I was used one example from telerik help like below for combobox.

Dim colName As String = radGvItemDetail.MasterGridViewTemplate.CurrentColumn.UniqueName

If colName = "ItemName" Then

Dim ComboEditor As New RadComboBoxEditor()

Dim ddlItemName As RadComboBox = TryCast(ComboEditor.HostedControl, RadComboBox)

ddlItemName.BindingContext = radGvItemDetail.BindingContext

Dim cell As GridComboBoxCellElement = TryCast(radGvItemDetail.CurrentCell, GridComboBoxCellElement)

ItemDs = DDLPopulate("SELECT ItemIntCode,ItemName FROM TB_Item_Master ORDER BY ItemName", "ItemName")

ddlItemName.DisplayMember = "ItemName"

ddlItemName.ValueMember = "ItemName"

ddlItemName.MaxDropDownItems = 8

' Use the RadComboBox data vitualization

ddlItemName.IntegralHeight = True

ddlItemName.BeginUpdate()

Dim comboitem As New RadComboBoxItem()

comboitem.Value = 0

comboitem.Text = ""

ddlItemName.Items.Add(comboitem)

ddlItemName.DataSource = ItemDs.Tables(0).DefaultView

ddlItemName.EndUpdate()

e.Editor = ComboEditor

If ddlItemName IsNot Nothing Then

AddHandler DirectCast(ComboEditor.HostedControl, RadComboBox).SelectedValueChanged, AddressOf ItemNameComboChange

End If

End If

By same like that what is the equalant code for gridviewtexbox column.

I was used below method but its not working.

Dim TextEditor1 As New RadTextBoxEditor

Dim txtItemName1 As RadTextBox = TryCast(TextEditor1.HostedControl, RadTextBox)

 Regards,
Sakthi

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 29 Feb 2008, 04:23 PM
Hello Sakthivel,

Thank you for writing.

Indeed, you cannot use the same approach to convert RadTextBoxEditor.HostedControl to RadTextBox. The reason is that RadComboBoxEditor inherits RadHostItem which wraps in its HostedControl property an instance of RadComboBox control.

Unlike RadComboBoxEditor, RadTextBoxEditor inherits from RadTextBoxItem, which exposes all events you need itself. So in your case, you do not have to cast at all. You just have to attach to the necessary events of RadTextBoxEditor.

Note: If you are looking for TextChanging/TextChanged events, I would suggest to you to use the corresponding events of RadGridView - ValueChanging/ValueChanged.

If you have any other questions, please do not hesitate to write me.

Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sakthivel
Top achievements
Rank 1
answered on 03 Mar 2008, 04:32 AM
I am not able to get the textbox value on textchanged events of that grid. Please post me some examples for the same.

Regards,
Sakthivel
0
Georgi
Telerik team
answered on 05 Mar 2008, 04:09 PM
Hello Sakthivel,

You could get directly the value of the editor by getting the value of its Text property. However, if your scenario requires something else (or is more complicated), please give us additional details about it so we could find the proper approach.

I hope this helps. If you have any additional questions, please contact me.

Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Sakthivel
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Sakthivel
Top achievements
Rank 1
Share this question
or