|
EdgarBM wrote:
Do you know anyway to begin?
You might start by searching google for examples. The following search turned up several good results: http://www.google.com/search?q=C%23+USB[^].
Because of the shear volume of native calls, the typical solution is to build a mixed-mode Managed C++ assembly. You can then reference the assembly in a C# project for easier use. Many of the articles include sample assemblies that already contain the necessary functionality. A link in the third search result contains sample code on MSDN: http://msdn.microsoft.com/msdnmag/issues/02/10/netserialcomm/[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello!
when I add a new item to my ListBox ,I want to choose a new color for
it(different color from other items).
Can I make it? or is there any method I can distingush some items from
other items except by selecting them.
Or to I have rewrite the ListBox ,to make it have this function.
waiting for help
|
|
|
|
|
You have to owner-draw your ListBox . Since its Items collection property can take any object, you can extend the ListBox and override the protected CreateItemCollection method to instantiate and return a typed collection, which you could inherit from CollectionBase (or make your own from scratch). You don't have to do this, but it gives you a little more control.
With or without doing that, when drawing your items, you could either imply a backgroud color based on the item position, or check if the item is of a certain type. For example, if the type is the class that follows, cast it and grab the BackColor property:
public class ListBoxItem
{
private string text;
private Color backColor;
public ListBoxItem(string text, Color backColor)
{
this.text = text;
this.backColor = backColor;
}
public string Text {get{return text;} set{text = value;}}
public Color BackColor {get{return backColor;} set{backColor = value;}}
} As far as owner-drawing the ListBox , there are many articles about that here on CodeProject. Just try the following search: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=ListBox+owner+draw[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to make automated ebay bidding program...
I have tried with web browser control and webclient class(c#)....
Web Browser control is too slow and hard to use in C#..
So I tried with webclient class.. Sending with form data was easy.. but the problem is cookie.. The cookie from header data can be read and set again.
But THE IMPORTANT PART is the cookies made form webbrowser itself by javascript..
Ebay send me a page wite this message "Your web browser doesn't suppor cookeis..".
I do not know how to read this cookes and set again...
Please help me frieds~~
kmmccc form south korea..
|
|
|
|
|
Are you trying to screen scrape the data off the page and have your application interpret it? It kind of sounds like that is what you are doing.
There are details about how to access eBay programmatically on eBay's developer site[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi,
1. I Designed MyEditor inherited UITypeEditor
public class MyEditor: System.Drawing.Design.UITypeEditor
{
private IWindowsFormsEditorService edSvc = null;
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
if (context != null&& context.Instance != null
&& provider != null)
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof
(IWindowsFormsEditorService));
if (edSvc != null)
{
// Form Create
FormMyEditor dlg = new FormMyEditor((string) value);
if( edSvc.ShowDialog(dlg) == DialogResult.OK)
{
context.OnComponentChanged();
}
}
}
return value;
}
public override UITypeEditorEditStyle GetEditStyle
(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
}
2. Mapped MyEditor at Property
public class UserInfo
{
private string userName = string.Empty;
[Category("UserInfo"),DesignOnly(false)]
[Editor(typeof(MyEditor), typeof(UITypeEditor))]
public string UserName
{
get {return userName;}
set { userName = value; }
}
public UserInfo(){}
}
3.At RunTime, generally, MyEditor worked well at form application.
but, MyEditor did not work in other form application.
.NET called default string editor.
why .NET didn't call MyEditor in some case ?
thanks to regards!
|
|
|
|
|
Do we have the concept of meta tags in RTF file such that it should hold the object of different file like ladder diagrams?
Does it calls for OLE in C#? Please guide
regards
|
|
|
|
|
This really has nothing to do with C#. If you're wondering about the RTF specifications, see http://support.microsoft.com/default.aspx?kbid=86999[^], which contains the link to download the RTF v1.7 specifications.
BTW, OLE isn't related to .NET, either. It's its own specification. .NET can interop with OLE and expose automation interfaces, but this isn't recommended. If you know anything about native COM with C++ or ATL, I suggest you use that. Exposing COM interfaces from .NET still requires the .NET Framework to be installed on the machine viewing the RTF (if you want them to see/use your OLE controls).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey the Remoting which is available in Normal Windows Application is not present in a Windows CE environment so if any one knows what alternatives are available and how they can be used to achieve remoting in a Windows CE environment please notify. Reply Soon.
Thankyou.
|
|
|
|
|
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
|
|
|
|