|
Encoding.<UTF8|ASCII|Unicode|...>.GetBytes(yourstring);
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello!!
I'm using C#
Assume I have an application containing a form named form.cs.
When you create the look for the form you use the form designer
to construct the look that you want.
All changes that you do in form designer are put into method InitializeComponent.
Assume the form have many more controls than these three controls mentioned just below.
The controls that are interesting for my question are:
Two buttons called put_in_box and get_from_box.
One label showing the correct time.
One datagrid.
The property for these controls is located in the InitializeComponent as I mentioned earlier.
Assume another customer requirement on the form is quite similar to form form.cs.
The only difference is that some controls should not be displayed and some other controls be added instead.
The followings controls should not be displyed for the new customer.
The two buttons named put_in_box and get_from_box.
A label showing current time.
A datagrid.
The new customer want to have a combobox in the same location as the datagrid.
We can assume that if you compare the appearance of the form between the two customer much is the same.
Now to my problem.
1. I want to have only one form in this case form.cs. So no duplication of code.
2. In an easy way being able to have two appearance(look) of the same form which is named form.cs.
3. Being able to change the appearance(look) for any of these two customer in an easy way..
4.The form designor is always looking for InitializeComponent when you want to change the appearance(the look) for the form.
5. If I had used MFC I would have used the resource files which store the look for a form in a named resource file. One customers look had been stored in one resource file and the other customer look would have been stored in another resource file but the code would only be in one place so no duplicate code
I can't find any good solution to my problem.
- One solution which is bad is to have two forms having one form for each customer which also duplicate the code. For example having form.cs and form_xyz.cs
- Another solution which is very bad is to have two InitializeComponent
InitializeComponent_abc and InitializeComponent_xyz. One for each customer.
When you want to edit the appearance(the look) for a customer xyz you have to rename InitializeComponent_xyz to InitializeComponent because the form designed is always looking for InitializeComponent. As a summary a lot of renaming here and there.
I wonder if you could help me with a good solution if there exist one.
//Tony
|
|
|
|
|
Tony,
It sounds like these are different applications, so I'd suggest creating different forms. Also, don't do *anything* to the code inside InitializeComponent() - your changes will most probably be lost. Instead, in the form ctor, add your changes *after* the call to InitializeComponent().
HTH.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
Hello!!
The main point is to avoid having to duplicate the code but if I use your suggestion then the code will be duplicated when I have two forms.
If I understand you right as you say these will be two separate application having it's own lives with it's own form.
Assume instead that the form between two customer were identical accept the colour on one single button. Do you still suggest that the best suggestion is to have two different application with it's own form.
I don't know if you are familiar with MFC but as I mentioned in the previous mail this is easy to solve in MFC.
So do you think that there doesn't exist any solution which is as good as the MFC solution of this problem.
If I just mention resource files. Resource files is having a different meaning and purpose in .Net compare to MFC. So to use resource files to solve my problem is not posssible in .NET(C#).
//Tony
|
|
|
|
|
There may be no best solution for it but here's some of my thoughts:
1. Seperate the logic and interface. You duplicate codes on the form but keeping the logics in 1 place. Probably this is too late for you to do now.
2. Have only 1 form, but a lot of switches to turn on/off the controls. But it will get very messy and confusing. I have seen forms and panels overlapping each other in one of our product and it's a nightmare just to look at the codes.
3. Put the core stuffs in a base form and inherit the forms into 2 forms (possible?), add new requirement on each new forms as required. If you have a 3rd requirement for new customer, it can support it well enough.
4. Duplicate everything into 2 forms. Harder to maintain but not as bad as (2).
Out of these few, I think 1 and 3 are the better one.
|
|
|
|
|
Hi all,
I would like to customize a text box so that it holds a collection.
How can this be done? (i.e.) I want to override the text box similar to a listbox, but only one item should be visible at a time and there should not be any scroll bar.
Thanks in advance.
Thanks and Regards
Madhu
|
|
|
|
|
you can derive a class from the TextBox class and then define
the properties that u want for the derived textbox.
you can define an object of the Arraylist to contain the collection
of the textbox.
Hope u get it
Regards,
Pramod
|
|
|
|
|
Thanks Pramod
But my problem was actually i need it the way as it is in list box.
i have provided an Items property and when i click on the ellipsis button i want it to display the string collection editor. But for me it returns an error telling no component.
How can this be resolved
Thanks in advance again
Thanks and Regards
Madhu
|
|
|
|
|
i don't know hoe to display the ellipsis button u can surely show the String collection editor,
for this u can create a form with the FormBorderStyle = none and put a Richtextbox on that form and then set the items property by reading each line of the Richtextbox.
Regards,
Pramod
|
|
|
|
|
Hi every body cloud u tell me how to register ActiveX contorl for flash exacly
"shockwave flash object" the control give me this error "Field to import the ActiveX control.Please ensure it is property registred".How to solve this problem???
Thank's
bye.
|
|
|
|
|
The best way to use with flash in your application, is to actually install flash in your deployment. You can get a distribution license, and the distribution version at Macromedia. Once you've got the file, add an Installer class to your application, and define a custom action for Install in your deployment project. In your Installer class, you override the Install method, and you use the Process class to run the flash installer.
|
|
|
|
|
I have it flash install in windows but how to get destribution version at micromedia.
|
|
|
|
|
|
Hi,
I have a simple project in WinForms (C# Express) .NET 2.0:
vo form I have inserted panel (panel1) and in panel there is PictureBox1
Panel1 has property Dock = Fill
PictureBox1 has property Dock = Top
on Resize event for picturebox I have:
/*----------------------------------------------------------------------*/
1 private void pictureBox1_Resize(object sender, EventArgs e)
2 {
3 Image newImg = new Bitmap(panel1.Width ,panel1.Height );
4 if (PictureBox1 != null)
5 {
6 if (PictureBox1.Image != null)
7 {
8 PictureBox1.Image.Dispose();
9 PictureBox1.Image = null;
10 }
11 PictureBox1.Image = newImg;
12 }
13 }
/*----------------------------------------------------------------------*/
After maximalisation of forrm has PictureBox unchanged size, although there is Dock property set to "Top".
When I comment line #11, everything works fine.
Why? I need to create image in PictureBox dinamically after each resizing of picturebox. However size of picturebox is not affected, and the worse it do something bad with Dock feature..
In .NET 1.1. it worked perfectly, however in .NET 2.0 it doesn't.
projekt is saved here: http://www.tekl.com/testform1.zip
( has 36kb).
Thank you for any help. I don't know, what to do.
|
|
|
|
|
try changing pictureBox1.SizeMode property to AutoSize.
While you use SizeMode=Normal, pictureBox always keeps it's starting size, unless you tell it to change it.
AutoSize mode will resize pictureBox to fully show image, each time image changes.
Robin Panther http://www.robinland.com
|
|
|
|
|
thank You so much! this was the reason.. SizeMode is new property in .NET 2.0
|
|
|
|
|
Hi, in my project, i am dealing with Sanskrit and Hindi languages, how should i read it from textbox and manipulate.
How should i read data from textbox in unicode form,..
Pls help me,..
Thanks
|
|
|
|
|
I thought .NET strings were all unicode by default ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i need to store the string written in sanskrit language in sql server, so, i should retrieve in unicode format, is nt it.
So,how can i do this.
If i am wrong, pls correct me?...
|
|
|
|
|
I also think that .net controls are unicode compatible, but your datatype in sql server should be nvarchar to support unicode data storage. and dont' forget to pass string allong with 'N' (character N) while passing string from .net to sql server. eg.
insert into Tmptable values(N'Text goes over here',32)
this will store your text as unicode compatible...
-Malli...!
|
|
|
|
|
Thanks 4 suggetion malli,
I have one doubt, how should i enter unicode text into textbox.
Simply said, how can i enter hindi or saskrit text into text box.
am i need to get, language support toolbar in xp.
I hope, u got me.
pls help me out in this issue.
Thanks
Shiva
|
|
|
|
|
I thought all .NET strings were unicode by default ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
From the string class yes. But you can write to streams using other encodings.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
my procedure is writing to an csv file... i have more than 900 to write in the csv files. i am able to write but the last 4 lines i would get an error object reference not set to an instance of an object. it wouldn't continue. but the other lines (1-900+) was written perfectly. can any one help me?
|
|
|
|
|
Not without seeing the code. You're plainly trying to call a method or property on an object which is null.
Christian Graus - Microsoft MVP - C++
|
|
|
|