accessing dfl objects

Milke Wey no.spam at example.com
Tue May 6 09:47:38 PDT 2008


On Mon, 2008-05-05 at 23:35 -0400, Tyro[a.c.edwards] wrote:
> I should probably be posting this somewhere else but hopefully someone here will be able to give me some advice.
> 
> Following the examples provided with DFL, I have created a tabbed form containing a number of text boxes, labels and a cancel and submit button. onSubmit_click I need to save the information contained in the text boxes to a file, likewise onCancel_click, I need to set all textboxes to null. Problem is I'm not sure how to access all the different text boxes to save or update the values.
> 
> all text boxes were created in the following manner:
> 
> TextBox transactionData; // this is the only variable I use for textboxes
> with(transactionData = new TextBox)
> {
>   // set properties;
> }
> control.add(transactionData)
> with(transactionData = new TextBox)
> {
>   // set properties for new button;
> }
> control.add(transactionData)
> //etc...
> 
> I've found that if I instantiate each TextBox at class scope, then I can access and update them later, however, since there will literally be hundreds of these boxes I don't want to have to declare a pointer to every single one. Is there another way?
> 
> Any assistance is greatly appreciated.
> Andrew

I don't use DFL myself but looking at the on-line documentation
something like this should do it.

foreach(ctrl; control.controls)
{
	TextBox textBox = cast(TextBox)ctrl;

	if ( textBox !is null )
	{
		//Do something with the text box
	}
}

-- 
Mike Wey



More information about the Digitalmars-d-learn mailing list