Hi, which control can I use to connect to sql server and get a list of database names (without manual implementation)? Currently I have to use manual code to get the database + table name then add to the some controls like treeview and listbox respectively
(I think I should use treeview because maybe I need to list database then whole table in the database but I'm not sure whether it supports this)
Thanks in advance!
5 Answers, 1 is accepted
Hello, Khanh,
You can use the Data Source Configuration Wizard in order to bind RadTreeView at design time. Then, you have to specify the DataSource, DisplayMember, ValueMember properties and add the necessary relations at design time as well. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/treeview/data-binding/binding-to-database-data
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hi Dess,
I have read that post, but it looks like I will have to do it manually.
from the code:
this.radTreeView1.DataSource = this.artistsBindingSource;
this.radTreeView1.DisplayMember = "ArtistName";
this.radTreeView1.ValueMember = "ArtistID";
Can I add them without knowing the specific names like: "ArtistName", "ArtistID" or not?
If my tables can be changed (name, quantity) I want to access them easily.
I mean a loop can add them, after I add databinding source to the control, I can do something like:
for (database db: treeview.datasource.database)
treeview.addnode (db.name);
and with tables..
I already understand how, if I want to create a right-click menu on this treeview can I do it or not?
I want to delete or add node through mouse right click event?
When you bind RadTreeView, you can't simply set the DataSource property. It is necessary to specify the DisplayMember, ValueMember properties and define the relation. Otherwise, RadTreeView wouldn't know how the applied data is organized and wouldn't be able to build the hierarchy.
As to the question about the context menu, it is necessary to enable the AllowDefaultContextMenu property. However, if you want to customize the context menu items, this can be achieved by handling the ContextMenuOpening event. The following help articles are quite useful on this topic:
https://docs.telerik.com/devtools/winforms/controls/treeview/context-menus/default-context-menu
https://docs.telerik.com/devtools/winforms/controls/treeview/context-menus/modifying-the-default-context-menu
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.