|
XML Web Services might be a possibility, but there's a lot of serialization overhead for a Pocket PC/Windows CE and you're limited to HTTP's client-response/server-request mechanism, so you can't use events.
The common approach described in articles both here on CodeProject, MSDN, and elsewhere on the web typically drop down to a lower level, defining a socket protocol. One such good article here on CodeProject is Creating Desktop Application Remote Controls with the .NET Compact Framework (Part 1)[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi ..
please see the code below..
I have two tables Centrals and Devices both having Central_Id as a common field..I am able to display the Centals table value in the first datagrid (dataGirdCentral).However on click of each cell on the central_id i want the corresponding entries of Devices table to be shown in the 2nd datagrid dataGridDevices..how do i do that...
private void loadCentralDevices()
{
ds = new DataSet();
//Getting schema of Centrals table
DataTable centralDt = new DataTable("Centrals");
String query = "Select * from Centrals";
OleDbDataAdapter da = new OleDbDataAdapter(query,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]);
da.FillSchema(centralDt, SchemaType.Source);
ds.Tables.Add(centralDt);
//Getting schema of Devices table
DataTable deviceDt = new DataTable("Devices");
String query1 = "Select * from Devices";
da = new OleDbDataAdapter(query1,ConfigurationSettings.AppSettings["MsAccess_ConnectString"]);
da.FillSchema(deviceDt,SchemaType.Source);
ds.Tables.Add(deviceDt);
DataRelation dr = new DataRelation("Central_Devices_Relation",
centralDt.Columns["Central_ID"], deviceDt.Columns["Central_Id"]);
ds.Relations.Add(dr);
//create a dataview of the data
DataView centralVw = new DataView(ds.Tables["centralDt"]);
//giving access to Centrals table
centralVw.AllowDelete=true;
centralVw.AllowEdit = true;
centralVw.AllowNew = true;
//set the grid source to the author view
dataGridCentral.DataSource = centralVw;
//hook up the event handler
dataGridCentral.CurrentCellChanged+= new EventHandler(this.dataGridCentral_CellChanging);
}
private void dataGridCentral_CellChanging(object sender, EventArgs eArgs)
{
????? what do i write here to get the corresponding values?
}
Breath dot net
|
|
|
|
|
Make the nested grid in the ID column. You must design the colum as template <templatecolumn>. Then in the grid_ItemDataBound you assign the data to the second data grid. This is the way how I would go.
Vasek
Vasek
VB6, C#, MS DNA, MS.NET
Software Developer
|
|
|
|
|
That would only work for ASP.NET. Hopefully this person did not mean that, otherwise it should be in the ASP.NET forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You do that by setting up a DataRelation between the PK and FK in your two DataTable s. See the .NET Framework SDK for more information about the DataRelation class.
Then, in the first DataGrid , set the DataMember to be the name of the first table. The DataSource would be the DataSet . For the second DataGrid , set the DataMember to FirstTableName.RelationshipName (of course substituting the first table name and relationship name you specify for the DataRelation ). The DataGrid s will handle the master/detail view automatically for you then.
For more information about this, see the DataGrid.DataMember property documentation in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok here is the problem all the keys on my keyboard works with my apps on the WinForm "this.KeyDown += new KeyEventHandler(...)",but i want to use the up, down, left, right keys and they dont work (the keydown event). Even the same keys on the number pad dont work when i turn off the "Num Lock". How can i get these keys working ?
modified 16-May-21 21:01pm.
|
|
|
|
|
They are all special keys and they are handled by the .net differently. Still if u want to use the handling of keys u can directly override the methods like ProcessCmdKey as below.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
{
MessageBox.Show("Up");
return true;
}
return base.ProcessCmdKey (ref msg, keyData);
}
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyData == Keys.Up )
{
MessageBox.Show("hahaha");
}
}
To handle the special keys the ProcessCmdKey override alone enough. Still I have added an event handler also for the Up Key Down event. This will not work as such if you run the code. To run the Event Handler code also you change the return true to return false in the ProcessCmdKey code.
What you know from this is the Arrow keys will be handled or not depends on whether it is already handled by the form or not. ie it depends on the return value of the base.ProcessCmdKey value, if you dont override it. The return value depends on the Control which has the focus, etc.
|
|
|
|
|
How do I set up a parameter so when it postbacks I can then use it in one of the asp.net controls event handlers.
Brian
|
|
|
|
|
|
Hi
Does anyone know how to load and read the methods and properties of a dll through c# ?.
Please assist me with sample codes!!!
|
|
|
|
|
You need to understand the structure of a PE/COFF executable, and only then can you get the exported functions, structs, and classes. This is done by enumerating virtual directories in the PE/COFF executable headers and using the Relative Virtual Addresses (RVAs) to get the functions from the Export Address Table (EAT).
See the following two articles, both my Matt Pietrek for MSDN Magazine:- Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format -- MSDN Magazine, February 2002
[^] - Inside Windows: An In-Depth Look into the Win32 Portable Executable File Format, Part 2 -- MSDN Magazine, March 2002[^]
In order to implement the code correctly, you may need an unsafe context (it's possible without, but tedious) and you also need a good grasp on unmanaged interoperability. For more information on that, read Interoperating with Unmanaged Code[^] in the .NET Framework SDK.
If there is already sample code, I'm not aware of it (hey, I'm not google ). You could try searching for a sample using keywords from the articles above, or even searching for "C#", "RVA", etc.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
BTW, if you're talking about reading the metadata of an assembly DLL (as opposed to a native DLL), then you should use .NET Reflection. See the documentation for the classes in the System.Reflection namespace in the .NET Framework SDK. For an overview and samples, read Discovering Type Information at Run Time[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a picture on picture box and I want to press a button to print it but it not work
how can i correct this:
<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
try<br />
{<br />
PrintDocument pd = new PrintDocument();<br />
pd.Print();<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("An error occurred while printing", ex.ToString());<br />
}<br />
}<br />
<br />
private void pd_PrintPage(object sender, PrintPageEventArgs ev)<br />
{<br />
string path = @"D:\PatientImages\10.jgp";<br />
ev.Graphics.DrawImage(Image.FromFile(path), ev.Graphics.VisibleClipBounds);<br />
ev.HasMorePages = true;<br />
}<br />
<br />
and i want to print direct to printer so how can i do it?
Thanks in advanced
Rock Throught The Night
|
|
|
|
|
First of all, you don't need to reload the Image if it's already in your PictureBox . Just use ev.Graphics.DrawImage(pictureBox1.Image, ...) .
Second, are you getting any errors? Is your MessageBox in your exception handler showing up? Please be specific since your code should be right (except that if you're scaling the image to the page, I'm not sure why you're setting ev.HasMorePages to true ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
please show me how to pint the image by using the printer when i pess the print button
thanks
Rock Throught The Night
|
|
|
|
|
Um, call PrintDocument.Print like you already did. If you want to know how to select a different printer, then you need to read the documentation in the .NET Framework SDK, like for the PrintDocument.PrinterSettings property, which has a printer called PrinterName . You can also use the PrinterSettings.InstalledPrinters static property to get a collection of printers that are installed. All of these properties and methods I've mentioned have plenty of sample source code that's not worth duplicating here.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
When i built My Solutions, mostly Assembly version automatically increased, but some case, Assembly Version lessoned.
I did not modify AssemblyInfo.cs file.
in Assemblyinfo.cs file,
version is [assembly: AssemblyVersion("1.0.*")]
Why version lessons?
Is there any way recovering version?
thanks in advance.
SeungPil Lee
|
|
|
|
|
The assembly version is generated according to the documentation for the AssemblyVersionAttribute in the .NET Framework SDK. From the constructor documentation:The format of the version string is: major. minor. build. revision.
When specifying a version, you have to at least specify major. If you specify major and minor, you can specify an asterisk (*) for build. This will cause build to be equal to the number of days since January 1, 2000 local time, and for revision to be equal to the number of seconds since midnight local time, divided by 2.
If you specify major, minor, and build, you can specify an asterisk for revision. This will cause revision to be equal to the number of seconds since midnight local time, divided by 2. So, as you should see, the version is generated using the current time. If your system clock is off or different computers are using different times zones (more common than you think, especially if someone has "Change automatically for daylight saving time" checked and another doesn't), then the version number will decrease.
Let me make a new case for you, though: disable automatic versioning! If you truly understand assembly strong names (which include the version) and manage larger solutions, you'd know why. Version numbers can quickly get out of control when using automatic versions. This is especially troublesome when you have a common build directory in a large group of developers. If assembly versions are changing all the time, you get FileNotFoundException s since the assembly version that the calling assembly was built against doesn't exist. You can - through .config files or publisher policy assemblies - redirect these versions easily enough (at least if there's no breaking changes) but it becomes a nightmare to manage those as well. Trust me - I'm a software architect and build master for a 60+ project solution with lots of dependencies.
Read Redirecting Assembly Versions[^] and Creating a Publisher Policy File[^] for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for answer.
It's helpful to me.
I see what you said.
When I built assmebly. i changed my computer time to past time.
|
|
|
|
|
Dear All,
The scenario is, I am in the phase of developing a print module in C# that will extract data (text, images, ladder snippets) from the project file stored in the computer's memory.
Earlier, I was trying to create an RTF file and create a project report like document, but that idea was ruled out as the amount of data is very huge.
Thus I am not supposed to create a seperate file for printing that will either be previewed or printed with the customized dialogs, as it will be an overhead to the system also it may affect the speed of the system.
The prime objective is to do printing/previewing as fast as possible.
Now I think, have only one option, that is, to create the document using Graphic Object( in GDI+ ) at run-time, using PrintPageDocument.
Its not really eassy task for me, first of all creating a formatted file like a project report that has title , creaters name and date on first page, then rest of the pages having different sub-headings, data in simple tabular format , bitmap images and ladder snippets, is a big question then inserting ladder diagrams in to it is also unthinkable, as I don't know how to read ladder diagrams using C#.
I will appreciate your every single suggestion. Please guide.
|
|
|
|
|
There are actually plenty of open-source projects available that already do this you should take a look at (which begs the question, if so many free and commercial libraries exist - why are you creating your own...unless it's for educational purposes).
For example, take a look at the Report.NET[^] project on SourceForge.
There's also a good one here on CodeProject: Printing Reports in .NET[^].
As you've already guessed, this is a complicated task. I suggest plenty of research into the System.Drawing namespace members, as well as child namespaces members, as well as research into what other projects are already doing. Many of these projects spawn from people with a lot of experience with report libraries, including some that have written them for other languages / platforms.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm having a bit of a problem with Commerce server's Bizdesk.
Ive had to write some extra modules to add into bizdesk, which all work fine appart from one problem, the rest of bizdesk seems to work off cached data which only periodically is written back to the db, where as my modules interact directally with the db. So when you make a change on something and then open up one of my modules, the change has not occurred yet.
I know that restarting the website or the app domain flushes all the cached data and gives me the desired effect because i've done it manually, but i cant be there to do it every time, so I want to write some code on a web page that will restart the website or app domain.
Unfortunatly i have no idea how to do this
please help
|
|
|
|
|
This really belongs in the ASP.NET[^] forum, but since it's a simple question I'll answer anyway (just please use the appropriate forum next time). Read about the HttpRuntime.Close static method. It flushes all items in the cache.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've successfully created & installed a Windows sevice. (It's easy with c#!).
However there are two additions I need to make which I can't figure out:
a) how to provide a command-line input to it. I need to tell the service where to find and store certain files: in particular, when it is installed, the service needs to know where the user has chosen to install the other files of the application.
b) In the 'Services' section of the Computer Management Console, is it possible to set a property 'Allow Service to Interact with Desktop'. I would like to set this programmatically, but cannot find the corresponding property in the the System.ServiceProcess namespace.
Any ideas?
|
|
|
|
|
a) The best place is in the application's .config file. The file is named the same as the application plus ".config" as the extension (ex: MyApplication.exe.config). This goes into the same directory. It's a simple XML file and there's plenty of documentation in the .NET Framework SDK.
For an installer to change this file, though, isn't so easy. Using VS.NET's crappy Windows Installer project, you'd have to extend the Installer class that takes a parameter that is the filepath to the service. It's possible, but not easy.
Though it's not recommended for .NET application, you might consider the registry, which the Windows Installer projects can right to easily. Let your service executable reside in the Application Folder in the Windows Installer project (this corresponds to the INSTALLDIR property) and then add a key under HKEY_LOCAL_MACHINE\Software\YourCompanyName\YourProductName somewhere. Set the registry value as [INSTALLDIR] (notice the brackets, which is important). Then your service can read from that registry key using the Microsoft.Win32.Registry and RegistryKey classes.
b) There is no way through the .NET FCL assemblies to do this, other than writing to the registry yourself. Under HKEY_LOCAL_MACHINE\SYSTEM\Services\YourServiceName (not the display name, but the short name you've given it), write a binary key named "Type" with the value 288. This is a flagged key where 32, IIRC, is "Local system account" and 256 is "Allow service to interact with desktop".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|