x


SQL Read Data Create buttons

Hey everyone,

I have a connection to a MS SQL database. The Query sends a simple "Select Column1 From MyTable"

Ive been able to populate using a label, the results

However, I cant seem to figure out how to tell it to create a GUI.Button for each row that gets reported back.

The Gui button would obviously fire another SQL Query once selected, but that i can handle.

Any advice would be really helpful

more ▼

asked May 06 '12 at 06:36 AM

jeubank28 gravatar image

jeubank28
1 1 1

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You can also use for loop to create the buttons

void LessonWindowList( int windowID ) {

    scrollPosition = GUILayout.BeginScrollView( scrollPosition );
    for( int x = 0; x <= yourLimit; x++ ) {
       if( GUILayout.Button( "no: " + x ) ){
       }
    }
    GUILayout.EndScrollView();
more ▼

answered May 10 '12 at 05:50 AM

pando gravatar image

pando
0 1 1 1

(comments are locked)
10|3000 characters needed characters left

[CODE]

//create list of buttons

void LessonWindowList ( int windowID ) {

    scrollPosition = GUILayout.BeginScrollView( scrollPosition );
    if( _GameItems != null ) {
       if( _GameItems.Count > 0 ) {
         foreach( data itm in _GameItems ) {
          if ( GUILayout.Button("Button Label Name) ) {
               //WHATS HAPPEN IF USER CLICKED THE BUTTON
              }
          }
         }
       }
    }
    GUILayout.EndScrollView();
}

[/CODE]

_GameItems contains the list of your data from database.

more ▼

answered May 09 '12 at 08:27 AM

pando gravatar image

pando
0 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1396
x819
x66

asked: May 06 '12 at 06:36 AM

Seen: 487 times

Last Updated: May 10 '12 at 05:50 AM