|
Hi all,
In VC++, in CRichEditControl class have a method naming 'LineScroll'. This method is used to scroll HScroll to any line. Would you tell me method in C# that similar LineScroll method of CRichEditControl class in VC++.
Thank you very much,
|
|
|
|
|
You could implement a similar method using P/Invoke:
public class ExtendedRichTextBox : RichTextBox
{
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
IntPtr wParam, IntPtr lParam);
const uint EM_LINESCOLL 0x00B6;
public void ScrollToLine(int line)
{
IntPtr lParam = new IntPtr(line);
SendMessage(Handle, EM_LINESCOLL , IntPtr.Zero, lParam);
}
} This will not extend past the last line. Read in the Platform SDK about the EM_LINESCROLL message for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi all,
What is the best design of data schema for a custom form ? (i.e. the user can add more fields to a form according to his own need) Any reference for this kind of data schema design ?
Thanks
|
|
|
|
|
What you ask is pretty ambiquous. Are you trying to define a form using an XML file? That's been done over and over. Look at XAML from Microsoft (.NET will support this in the future, and Microsoft has announced plans to support this down to Windows 2000, IIRC - not just "Longhorn") or Myxaml[^] from our very own Marc Clifton.
Or is your data schema a DataSet that will be used to update a database, and you want to design a Form to fill fields based on what is in the DataSet schema?
I can think of many other things you might mean, too, so please explain exactly what you're trying to do.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for your reply.
I mean the relational database table schema. Consider the database schema for a custom form which is extensible (the user can put more fields on the form).
e.g. for the fields in a form
Table schema :
Name string
Address String
City String
Then the user add more fields later :
Name string
Address String
City String
Country String
phoneNo int
faxNo int
So what should be the design of the relational database schema that
can allow the user to extend arbitrarily ?
Thanks
|
|
|
|
|
You can either do it like Microsoft SharePoint and store the data in a single ntext field, or use an many-to-many relationship to define the columns and contain their data:
Column
------
ID: int (key)
Name: nvarchar(64) (w/ unique constraint (not key; too slow for text))
Type: nvarchar(256)
Description: nvarchar(256)
Values
------
ColumnID: int (FK to Column.ID)
DataID: int (FK to Data.ID)
Data
----
ID: int (key)
Value: ntext (serialized value; easy to represent data across platforms) Something along those lines works and I've used it before.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I want to change ShortDate Format from System Regional setting.At the first time i asked,someone replied me to use System.Globlization .but i can't use it. Pls Advise me for that Problem.
|
|
|
|
|
Not an answer but why can't you use System.Globalisation? I think you will be in for a world of hurt if you don't use the built-in namespace. Modifying it yourself will mean doing it at every point your app displays or inputs a date.
regards,
Paul Watson
South Africa
The Code Project
South-East Asia Disaster: How you can help
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
whats the easiest way to set a richtextboxs font to Terminal and how would i know what the family of a particular font is
|
|
|
|
|
|
Can we send a Form type object from a Remote Server.
If yes then how.
Actully I have tried it but I could not succeed.
|
|
|
|
|
|
System.Windows.Forms.Form inherits indirectly from System.MarshalByRefObject , so there is no reason why it can't be remoted - in fact, I just knocked up a test server/client then and succeeded.
However, as leppie said, you can't pass a window handle across remoting boundaries - they mean nothing on two different systems.
You'll have to expose the object (probably as a client-activated type), but there is a snag: you cannot pass your form as the parameter to Application.Run() .
This is because Application.Run(Form) will actually create a new ApplicationContext based around your form and then attempt to attach a delegate to your form's HandleDestroyed event so that it knows when to terminate the message loop. The problem is that ApplicationContext is not remotable (i.e., not derived from MarshalByRefObject nor is it marked as Serializable ), so you can't pass the target method information in the delegate across the remoting boundary. This will result in a SerializationException .
Instead, use Form.ShowDialog(). That will work.
Good luck.
This space for rent!
My Blog
|
|
|
|
|
Actually, I'm going to have to eat my words here.
Read This.
My tests were succesful - when the remote server and client were run on the same machine. Not only that, what happened was that the form was not displayed in the client process, it was displayed in the server process! Totally useless.
If you run the server on a seperate machine on your network and attempt to connect with the client, you'll end up with a RemotingExcption , telling you that permission was denied to create the instance of the form. I'm not sure why this occurs.
Hmm. Oops. Oh well, all part of the learning experience
This space for rent!
My Blog
|
|
|
|
|
Hi all,
I am design a three layer system in C# (view layer, business object layer
and data layer). But when I look into the J2EE infrastructure, the object
bean(business object) incorporates the SQL data function into the object itself. It seems violates the layer design principles coz it mixes the data layer with the business object layer. But in the other hand, it seems a more OO design coz the business object integrates all those related information into the business object, so when there is a later change in the business object specificiation, the developer needs to change only the business object instead of changing the object and the data layer.
So what approach should I choose ?
|
|
|
|
|
I think the whole decoupling of the data-layer from the business-layer is overrated.
The main benefit touted is being able to switch to different data providers. But how many apps and users ever do this? If you need to do this, and I mean really need to, then your course is already chosen.
If not then go with the easier and more efficient second option you mention.
regards,
Paul Watson
South Africa
The Code Project
South-East Asia Disaster: How you can help
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
Hi,
I did a program and in that part i have given a loop. This is a program which reads any xml schema file and according to their datatypes , It creates 200 values in a xml file. Each values should differ from the other. I have done it for other datatypes. But for DateTime, I dont know how to change the data, Pls have a look through and sent me. Its very urgent for me now. I ma sending the loop part alone and I will mark my dobtful part alone in bold . just give an idea how to do.
private void button2_Click(object sender, System.EventArgs e)
{
dataSet1.ReadXmlSchema(txtSchema.Text);
foreach (DataTable dTbl in dataSet1.Tables)
{
for(int j = 0; j <= 200; j++)
{
object[] oValues = new object[dTbl.Columns.Count];
int i = 0 ;
foreach (DataColumn dColmn in dTbl.Columns)
{
switch(dColmn.DataType.ToString())
{
case "System.String":
oValues[i] = (string) "This is string" + j;
break;
case "System.DateTime":
oValues[i] = new DateTime(2004,10,12) ;
break;
}
i = i+1;
}
dTbl.Rows.Add(oValues);
}
}
}
santhosh
|
|
|
|
|
Are you asking how to increment a DateTime? If so then use oValues[i] = new DateTime(2004,10,12).AddDays(j); in your code. That will add a number of days equal to j onto your base date of 2004,10,12. You can also add minutes, seconds, hours, months, weeks or years using the various methods of the DateTime class.
regards,
Paul Watson
South Africa
The Code Project
South-East Asia Disaster: How you can help
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
Thanx paul. I got the result. Your information helped me out to get the result.
John santhosh
|
|
|
|
|
Does anybody know the code for opening a browser window from C# windows code. I had tried to use the System.IO.File construction without success. The file may in fact open if I open a .htm file alongside the windows application, but it does not open the browser window.
I would need to know how to open a browser window from a menu item, and second how to open an .htm file that would download a file from a remote internet web server, that would place the file in a specific directory. Any suggestions for a different way to approach this dilemma? I know that it is possible, because I have seen some applications do it.
|
|
|
|
|
The easiest way is to use Diagnostic.Process and the Start method as explained in this CP artile; Using Diagnostics.Process to start an external application.
If you pass in a full URL then Windows will know which app to open e.g. Internet Explorer or FireFox or whatever the default URL handler is.
As for your second question you could pass the URL of the file to download and Windows will handle it in the usual manner when downloading files from the net. i.e. It will open a Save As/Open dialog.
regards,
Paul Watson
South Africa
The Code Project
South-East Asia Disaster: How you can help
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
Paul Watson:
Thanks, I appreciate the input. However, is it possible to download the file from the net "without" opening the save as dialog box, and to simply place the file into the required directory for further processing? And if so, should a timer be activated to make certain that the file has been completely downloaded?
|
|
|
|
|
If you are running an app on the users machine then sure, you can download a file and put it on the users machine. You can run it too once it is down.
You can use the WebRequest class to get files over HTTP. You can then use a stream writer to write it to disk.
regards,
Paul Watson
South Africa
The Code Project
South-East Asia Disaster: How you can help
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
I was wondering how can I have my application setup and recieve global shortcuts. Basically, I want my program to run in the background and recieve the shortcut no matter what application has focus (kind of like WinAmp does).
Where can I find articles/example code on this? Or where should I start to look in the SDK?
Thanks for all your help!!
|
|
|
|
|
I believe you'll have to use some Windows Hooks for this. I read an article on it once, I just have to find it again...
Here it is:
http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/
Here's a good one about global hooks from CP.
There are two types of windows hooks: local hooks, which catch messages coming in for one particular thread, and global hooks, which catch messages for all threads on the entire system.
This space for rent!
My Blog
|
|
|
|