Want to make Scrollable DataGrid [with rows and column], please help

Greetings,

   customerSearchResult = www.text.Split('\n');// for rows
		int length = customerSearchResult.Length - 1;

This is my simple code.
customerSearchResult , has the records as you can see
length , tells the number of rows

I want to create the number of rows equals to the value of length [for example if length is 40, then 40 rows] and assign the value to each rows as per customerSearchResult

And if i click on them, i want its value in Debug.Log

Please help me

Not exactly sure if this is what you are asking for. But this:

//This is C# btw
//rather then a www call I'll use this for a example
	public string wwwString = "Joe\nBob\nKevin\nBob\nKevin\nBob\nKevin\nBob\nKevin\nBob\nKevin\nBob\nKevin\nBob\nKevin";
	public string[] customerSearchResult;
	public Vector2 scrollPosition = Vector2.zero;
	private int length = 0;
	
	// Use this for initialization
	void Start () {
		//again only using example string
		customerSearchResult = wwwString.Split("\n"[0]);
		length = customerSearchResult.Length;
	}
	
	void OnGUI(){
		scrollPosition = GUI.BeginScrollView(new Rect(0, 0, Screen.width, 70), scrollPosition, new Rect(0, 0, 50*length, 50));
		
		for(int i = 0;i < length;i++){
			if(GUI.Button(new Rect(50*i,0,50,50),customerSearchResult[i])) print(customerSearchResult[i]);
		}
		GUI.EndScrollView ();
	}

Will give you a result that looks like this:

The key to this whole gui structure being GUI.BeginScrollView. Hope it helps.

  • how about create datagridview from sql to unity?
1 Like