i need to bind values from db to gridview textbox column, but i noticed there is no way to bind th开发者_运维百科at in griview textboxcolumn in telerik winform, if there is any solution for that will appreciate Thanks in advance Ashok.
There are a couple of examples here. Anyways, it seems to be the same as with the Windows Forms DataGridView.
Here's one example, taken from the link.
// Sample class
public class MyObject
{
public MyObject(int myInt, string myString)
{
_myInt = myInt;
_myString = myString;
}
private int _myInt;
public int MyInt
{
get { return _myInt; }
set { _myInt = value; }
}
private string _myString;
public string MyString
{
get { return _myString; }
set { _myString = value; }
}
}
// Binding to a Generic BindingList of Sample class
private BindingList<MyObject> myList;
private void Form1_Load(object sender, EventArgs e)
{
myList = new BindingList<MyObject>();
myList.Add(new MyObject(1, "Outdoor"));
myList.Add(new MyObject(2, "Hardware"));
myList.Add(new MyObject(3, "Tools"));
myList.Add(new MyObject(4, "Books"));
myList.Add(new MyObject(5, "Appliances"));
myList.RaiseListChangedEvents = true;
myList.ListChanged += new ListChangedEventHandler(myList_ListChanged);
radGridView1.DataSource = myList;
}
void myList_ListChanged(object sender, ListChangedEventArgs e)
{
MessageBox.Show(e.ListChangedType.ToString() + ": at index: " + e.NewIndex.ToString() + ", \"" + myList[e.NewIndex].MyString + "\"");
}
private void radButton1_Click(object sender, EventArgs e)
{
myList.Add(new MyObject(6, "Plants"));
}
精彩评论