|
You can't do this automatically.
If remote access was your requirement, you should be using .NET remoting. However this was a thing to consider in the design phase. Now that you already done some amount of coding, I am afraid you have to re-code to incorporate .NET remoting in your code.
Refer MSDN and Code Project regarding tutorials on this topic.
Salil Khedkar [^]
|
|
|
|
|
|
Thanks Carl. That is great.
Regards
Stephen
|
|
|
|
|
Hello,
I have a data grid that contains 5 columns. I want the columns to be displayed a different lengths at run-time. But l have tired using the properties but cannot find anything that will adjust the columns to the width that l require. They seem to stay at their defaulf widths.
Many thanks in advance,
Steve
|
|
|
|
|
The best solution is to just use defined table styles instead of auto-generated styles. Read about the DataGrid.TableStyles propert and related classes at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridClassTableStylesTopic.asp[^] in the online .NET Framework SDK (or simply type "DataGrid.TableStyles" in your local installation or in VS.NET's Index).
This allows you to specifically add one or more styles for one or more table names (or property names if binding to an IList or IListSource implementation other than a DataTable or DataSet ) that explicitly defines column styles for named DataColumn s (or inner property names).
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]
|
|
|
|
|
Hello,
I have adjusted some properties in the tablestyle and columnstyle design properties, but l still can't get it to work. This what l have done:
In my database l have a table called Book
I have 3 collumns called RefNumber, Title, and Remarks
my datagrid code to bind to the datatable is:
grdStudents.Source = dtStudents();
grdReflesh();
Now I design the datagrid columns shape.
In the datagrid properties i have a property called : tablestyles, inside it is a designer . I add a new tablestyle and make it's mapping = "Book"
so this table properties will be applied on the table called "Book" which is the name of the table
Inside this table styles there is a gridcolumnstyles property, inside it there is a designer, I add the columns I want inside it and set their properties (height,width etc....) and for each column set it's mapping name to the column names. I l have 3 columns styles mapped to RefNumber, Title, and Remarks.
After doing all this l still can't get it to work. I have used the datatable, but will this work with only using a dataset. I am not sure.
Thanks in advance for any help,
Steve
|
|
|
|
|
The column and table styles should be assigned before you set the DataGrid.DataSource .
If you actually read the documentation for DataGrid.DataSource , you'll see that any IList or IListSource will do. You can assign either a DataSet or DataTable , but I recommend assigning the DataSet to DataGrid.DataSource and the name of the table to DataGrid.DataMember . Finally, make sure that for your DataGridTableStyle you set the MappingName to the DataTable name (if you follow my advice above, this would be the same as the DataGrid.DataMember name, but still works if you assign the DataTable to the DataGrid.DataSource instead). The documentation for the DataGridTableStyle.MappingName describes this, as well as what to assign as the MappingName if you're reflecting against IList or IListSource implementations besides the DataSet and DataTable classes.
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,
I have a combo box and a text box on a form. cmb1 and txt1 for arguments sake. The tab order means that when tab is pressed focus moves from cmb1 to txt1. What i want to do is allow for the user to press the enter key and simulate the tab key being pressed, i.e. focus moves to the next control on the tab order.
Any ideas?
Cheers
Kev
|
|
|
|
|
You could check for the Enter key in the combo's KeyPress event, then transfer focus to the next in the tab order.
private void comboBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( e.KeyChar == (char)13 )
{
this.GetNextControl(this.ActiveControl, true).Focus();
}
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
You should actually use KeyCode.Enter . While this will probably always be character code 13, without optimization (based on the compiler) (char)13 may require additional instructions for the cast while using KeyCode.Enter will always compile to 13 without a cast.
Besides, it's best to avoid "magic numbers" and makes for more elegant code.
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 took this (the char 13) straight out of MSDN Library for the KeyPressEventArgs.KeyChar Property[^]. You might want to pass your suggestion on to MSDN Lib guys
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Thanks Roger,
Works great.
Kev
|
|
|
|
|
I'm trying to create rotatable widgets. I tried to rotate the graphic surface but that is not enough, I have to rotate the clip rectangle of the components too, in order to create the right paint area and to receive the mouse events in the correct way. Alternatively, I created my own components from scratch, and implemented everything, but I would rather use .Net components and just extend them. But I'm not sure if that is possible. Is there anybody who knows if it is possible and, if yes, how can I?
I am using C# with .Net 1.1.4322.
|
|
|
|
|
The Graphics class defines several helpful transformation methods like Graphics.RotateTransform for this specific purpose. If you apply this as the world transform, than even your clipping region (whether you fill a Region yourself or use a GraphicsPath (most handy, BTW!) is rotated.
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]
|
|
|
|
|
Thank you. But, I'm sorry, I don`t understand what you mean for "apply this as the world transform". If I extend a Button Class and I call RotateTransform to its Graphic obj it will only change the graphic surface, but not the . Can you give me a little example of your solution?
|
|
|
|
|
Because a Button isn't completely drawn by .NET. You must understand that almost every control in Windows Forms encapsulates the native Windows Common Controls which draws the control unless you completely handle the painting yourself by calling the following in your constructor:
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint,
true); For examples of transforms read the class documentation in the .NET Framework SDK that was installed by default when you installed VS.NET (or the standalone SDK) or available online at http://msdn.microsoft.com/library[^].
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]
|
|
|
|
|
First I'd like to point out that I am posting this anonymously to protect the identities of myself and those I work with.
At a design review meeting recently, a collegue of mine stated that we shouldn't use the reflection assembly in out software as using reflection was 'cheating'.
I have to say that I was completely speechless. My collegue appears to think that reflection is cheating as it allows you to bypass the class structure.
Personally I think that reflection is a useful addition to the .NET libraries and allows us to write flexible code.
Any views?
|
|
|
|
|
Fear of the unknown is a big reason for people to not like new ideas. Show some examples of how benefical reflection can be. However anything can be abused so make sure your proposed design isn't abusing reflection and that another sound design wouldn't work. Reflection used correctly can add great power, maintainability and flexability to a design.
Examples:
1) A pluggable container system that allows any component to be loaded/unloaded at runtime without the need to stop the server
2) Ability to use different adapters that can be configured through a external text file. I used this quite a bit and it saved an enormous amount of time and coding effort.
What exactly did you propose using reflection for?
-
Drew
|
|
|
|
|
Reflection is not cheating, it is just another tool in the toolbox. Like most other techniques (inheritance, singletone, etc) it can be used inappropriately, but that is no reason to dismiss it out of hand.
my blog
|
|
|
|
|
hello,
i'm looking for an open source implementation of a user modeling for information retrieval project.
the project is written in c# and the part i'm looking for should create a user profile for a specific web pages google retrieves.
if anyone heard of such an open source code, i'll be more than happy to hear about it.
my email is: kruhd@bgu.ac.il
thankyou,
Doron.
|
|
|
|
|
Hi there!
I want to know if you can help me in two little things.
First of all, I´m trying to put a XML new element in an existing XML.
The new element would be like this <name>C:\deco.mpg</name>
I´m trying to make this with this instructions
XmlElement elem = doc.CreateElement("name");
elem.InnerText = C:\deco.mpg;
node.AppendChild(elem);
but in XML appear like this
<name xmlns="">C:\deco.mpg</name>
How can I eliminate the (xmlns="")?!!!
The other doubt is the following, if I want to create an element and elements inside, for example...
<video>
<filetype>mpg</filetape>
<name>deco</name>
</video>
How can I do this?!!
Thank you very much, Sèrgio
|
|
|
|
|
the answer to your second question is simple create a root element instead a child element by adding properties to the new created element
at hte first question i am not sure bu i thing that is the namespace, there must be an option about it, refer to msdn...
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
The xmlns you should not worry about. It will not affect your XML-related code. If you're worried about it for asthetic reasons, then you should either define a namespace (in most cases, your XML documents should have unique namespaces anyway) or write the raw element using an XmlTextWriter instead, calling the WriteRaw method. Other methods in the XmlTextWriter would also help as well, but you need to read the class documentation in the .NET Framework SDK to gain a better understanding.
For second problem, as the other user mentioned below, just create yet another element like you are now, or use elem.InnerXml propety like so:
elem.InnerXml = "<filetype>mgp</filetype><name>deco</name>";
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!
How to convert the following VC++ code to C# code,what does the corresponding C# code look like?
HKEY CreateRegistryKey(DWORD *pdwStatus)
{
LONG lResult;
DWORD dwDisposition;
HKEY hKey = NULL;
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
subkey,
0,
NULL,
REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE,
NULL,
&hKey,
&dwDisposition
);
if(lResult == ERROR_SUCCESS)
{
if(dwDisposition == REG_CREATED_NEW_KEY)
{
*pdwStatus = REG_KEY_CREATED;
}
else if(dwDisposition == REG_OPENED_EXISTING_KEY)
{
*pdwStatus = REG_KEY_OPENED;
}
return hKey;
}
}
|
|
|
|
|
Why bother? Just use the Microsoft.Win32.RegistryKey class. Don't P/Invoke code (like RegCreateKeyEx ) if don't have to. This intrudoces additional security restrictions on your code. Microsoft has already define such methods in the BCL - and our assemblies are fully trusted - using the RegistryKey class I mentioned above.
If you want to learn more about P/Invoke, I suggest you start by reading Consuming Unmanaged DLL Functions[^] in the .NET Framework SDK.
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]
|
|
|
|