Hi,
I have a textbox (dynamically created textbox) into which i will write some text after reading a file. But the text in that is very big when compared to the form size. So what i did is i kept a button at the end of the textbox so that when user clicks on that i will increase or popup some dialog box which just shows the complete text in the textbox. how can i do that? The way how i added button to textbox is as follows:
[Description ("Sample string to be displayed in viewer"), Category ("Text Configuration")]
[EditorAttribute(StringSelect::typeid, System::Drawing::Design::UITypeEditor::typeid)]
property String ^ StringSelect
{
String ^ get()
{
return sample_string;
}
void set( String ^ val )
{
sample_string = val;
}
}
public ref class StringSelect : System::Drawing::Design::UITypeEditor
{
public:
virtual System::Drawing::Design::UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext ^ context) override
{
if(context != nullptr && context->Instance != nullptr)
{
return System::Drawing::Design::UITypeEditorEditStyle::Modal;
}
else
{
return System::Drawing::Design::UITypeEditorEditStyle::None;
}
}
[RefreshProperties(RefreshProperties::All)]
virtual Object ^ EditValue( ITypeDescriptorContext ^ context,
System::IServiceProvider ^ provider,
Object ^ value) override
{
if(context == nullptr || provider == nullptr || context->Instance == nullptr)
{
return value;
}
return value;
}
};
What ever the answer you are gonna give, if that is an extension of this that would help me better.
Thanks & Regards,
Karthik
Loading
VulpesPosted Aug 30, 2011, 3:54 PM
Sam HobbsPosted Aug 30, 2011, 12:27 PM
Probably part of the problem is that what you mean by "dialog box". A dialog box is a Windows API thing that is a separate window and the contents is provided by a template created by a resource editor that is like the VS designer but dialog boxes are totally separte from .Net; there is nothing in .Net for creating a Windows API dialog box. What do you mean by "dialog box"? Do you mean that you want something that is in the same form? If not then the answer seems obvious and I assume you would not be asking how to do it. So I assume you want to maximize a text box within the same form.
The question is, how do you want the user to get out of the maximized text box? How do you want the user to be able to cancel the edit when the need to? Do you need to have a multiline text box? All of those questions are relevant to the answer.
The easy part of the answer is that you can set the text box location to "0,0" or the top-left of the form, but I am sure you know that. Also set the size to the ClientSize of the form. I am not sure what you need to do to the other controls; probably it would work to disable and hide them. To allow the user to restore the text box to it's normal size and location you could use a menu item in a menu or a toolbar icon for doing that. If the application already has a menu and/or toolbar then using one or both of them for this also won't use up additional space in the form.
Karthik AgarwalPosted Aug 30, 2011, 10:32 AM
This is not a very good answer. I told you already that i am adding everything on to the Form at run time i.e dynamically. If this is the case how can you tell that just multiline textbox and button would do the job? That too my Form doesn't allow multiline textbox due to space restrictions.
VulpesPosted Aug 30, 2011, 10:17 AM