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

Look for the control toolbox used to list the database name (in sql server) ?

5 Answers 54 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Khanh
Top achievements
Rank 1
Iron
Khanh asked on 22 Apr 2020, 01:32 PM

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

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Apr 2020, 05:21 AM

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

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Khanh
Top achievements
Rank 1
Iron
answered on 23 Apr 2020, 08:14 AM
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..

 
0
Khanh
Top achievements
Rank 1
Iron
answered on 23 Apr 2020, 10:04 AM
hi dess,
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?
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Apr 2020, 04:45 AM
Hello, Khanh,

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

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Khanh
Top achievements
Rank 1
Iron
answered on 24 Apr 2020, 10:47 AM
Tthanks Dess, that's exactly what I need.
Tags
Treeview
Asked by
Khanh
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Khanh
Top achievements
Rank 1
Iron
Share this question
or