|
Hello there, i'm trying to connect to a contactless card reader via USB.
I'm using the SetupDiGetClassDevs -> SetupDiEnumDeviceInterfaces -> SetupDiGetDeviceInterfaceDetail -> CreateFile-> DeviceIoControl
But unfortuantly my method fails. I cant get the device handle from CreateFile , because the USB divice name that i get from the SetupDiGetDeviceInterfaceDetail cannot be directly used for the CreateFile.
My USB device name is \\\\?\\usb#vid_072f&pid_8003#5&1903a12b&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
But i guess the string has to be formatted is some kind of way so it can be used in the CreateFile method/ Please help !
|
|
|
|
|
|
Thank you for your answer but that doesnt help me at all
|
|
|
|
|
I'm working with a windows foem application. I have a dataset that was returned from a webservice. The third column ("Permanent") contains a bool. When i bind the data to a datagridview, that coulmn shows up as a series of checked checkboxes (since all the rows happened to have "true" for that value). What I want to do is modify the dataset, before binding it to the grid, to display the word "Permanent" if the bool is true and "Temporary" is the bool is false. I've gotten the code the point where I recognise whether it's true or false, but, because the column expects a bool, I can't put in the appropriate string. Any suggestions?
<br />
private void btnGetAccounts_Click(object sender, EventArgs e)<br />
{<br />
BindingSource bs = new BindingSource();<br />
dsAccounts = new DataSet();<br />
dsAccounts = myAccount.List(nSessionID, out nError, out sErrorMsg);<br />
if (dsAccounts != null && dsAccounts.Tables.Count > 0)<br />
{ <br />
for (int i = 0; i < 10; i++)<br />
{<br />
if ((bool)dsAccounts.Tables[0].Rows[i][2] == true)<br />
{<br />
dsAccounts.Tables[0].Rows[i][2] = "Permanent";<br />
}<br />
}<br />
<br />
bs.DataSource = dsAccounts;<br />
bs.DataMember = dsAccounts.Tables[0].TableName;<br />
dgvAccounts.DataSource = bs;<br />
}<br />
}<br />
The error I get is: "String was not recognised as valid Boolean. Couldn't store "Permanent" in Permanent column. Expected type is Boolean."
|
|
|
|
|
|
Close but no cigar. Or maybe it -is- a cigar, and I just don't know it.
The link does describe what I want to do, but I have a problems with it.
The example uses ASP and not windows forms. Thus it has a datagrid not a datagridview (datagrid is not available in windows form apps). Also the event "RowDataBound" is not an event that is available for datagridview. I could hand type it from scratch, but how would I make it fire at the right time?
|
|
|
|
|
Whoops, didn't notice it was ASP.net
The cell formatting event should do basically the same thing for c# if you set the datagridview column type to string
Ex.
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if ((bool)e.Value)
e.Value = "Permanent";
else
e.Value = "Temporary";
}
|
|
|
|
|
No joy. I got a "specified cast is not available" on the "if ((bool)e.Value)" line. However, I have an acceptable work around (though it may make thing slow when i get a lot of data flowing). I created a class "Account" with a class member variable for each of the four fields in my dataset, including the "Permanent" (where in my class Permanent is a string. So, once I get my data set, I create an arraylist of Accounts, looping through the dataset until it's done, copying each field of the dataset one at a time, modifying the contents as desired. Then I bind the arraylist to my datagridview.
Not as elegant as using an event, but may be better in the long term, as I have to deal with these accounts.
Here's the Account class:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestMTAccounts
{
public class Account
{
string m_AccountID;
public string AccountID
{
get { return m_AccountID; }
set { m_AccountID = value; }
}
string m_Name;
public string Name
{
get { return m_Name; }
set { m_Name = value; }
}
string m_Permanent;
public string Permanent
{
get { return m_Permanent; }
set { m_Permanent = value; }
}
string m_TermDate;
public string TermDate
{
get { return m_TermDate; }
set { m_TermDate = value; }
}
}
}
And here's the new method:
private void btnGetAccounts_Click(object sender, EventArgs e)
{
dsAccounts = new DataSet();
dsAccounts = myAccount.List(nSessionID, out nError, out sErrorMsg);
if (dsAccounts != null && dsAccounts.Tables.Count > 0)
{
ArrayList alAccounts = new ArrayList();
Account acctMyAcct;
for (int i = 0; i < 10; i++)
{
acctMyAcct = new Account();
acctMyAcct.AccountID = (string)dsAccounts.Tables[0].Rows[i][0];
acctMyAcct.Name = (string)dsAccounts.Tables[0].Rows[i][1];
if ((bool)dsAccounts.Tables[0].Rows[i][2] == true)
{
acctMyAcct.Permanent = "Permanent";
acctMyAcct.TermDate = "N/A";
}
else
{
acctMyAcct.Permanent = "Temporary";
acctMyAcct.TermDate = (string)dsAccounts.Tables[0].Rows[i][3];
}
alAccounts.Add(acctMyAcct);
}
this.dgvAccounts.DataSource = alAccounts;
}
}
}
I appreciate the suggestions, though!!
|
|
|
|
|
Hi
I want to print the data of the DataGridView by splitting the columns. That is each column of the DataGridView should split and should be displayed in individual tables on a form or Print view. For example the Print view of a DataGridView should look like this
# # #
# # #
# # #
Note: Here each # represents the table of a column of the table.
Here the number of rows and columns will change, so preferably the number of column's tables should change dynamically.
If any one know the solution Please kindly send me.
Thanking you
|
|
|
|
|
I would recommend using CrystalReports. But in order to help you more you need to try and draw us a clearer picture of what is your plan...
If you can, post a print screen of your desired final result and we'll see how it goes from there.
|
|
|
|
|
Thank you for your reply
If we have a table like this
Customer Details:
Customer Name E-Mail Phone Job Date
John John@gmail.com 34567 Code 31-01-09
Mary Mary@hotmail.com 67890 Design 01-02-09
Swetha Swetha@live.com 87654 Testing 02-02-09
then the Print View of this should look like this.
Customer Name E-mail
John John@gmail.com
Mary Mary@hotmail.com
Swetha Swetha@live.com
Phone Job
34567 Code
69890 Design
87654 Testing
Dates
31-01-09
01-02-09
02-02-09
i.e., each column of the Customaer Details Table should be displayed in a separate individual tables.
ex:if the table have 10 columns then in Printview 10 invividual tables for these columns chould be displayed.
How to display it dynamically in a windows form.Note that the number of columns and rows will vary dynamically
|
|
|
|
|
OK, it's actualy very easy thing to do.
The main idea is to use the subreports option in the crystalreport item.
You need to add a new DataSet item to your project (Add new item -> c# -> DataSet)
In this new dataset add new datatable and add rows according to your original table (i.e. Name, Email, and etc.) This DataSet will not be used to host the data, rether this will only be used to set as a Template for your report.
You add a CrystalReport item to your project (Add new item -> Reports -> CrystalReport)
In the wizard just choose standard and finish the wizard after doing so.
Now you should have a blank report with 5 sections.
Right click the the white blank area in between "Section 3 (Details)" to "Section 4 (Report Footer)" and choose insert -> subreport.
In the dialog the opens up choose "Create a subreport with Report Wizard".
Name the report with the title of what you wish to display (i.e. Name) and click on "Report Wizard..."
A new dialog name "Standard Report..." should opens up.
Expand Project data -> Ado.NET DataSets -> YOURDATASETNAME and by clicking the double arrows to the right of this treeview add your datatable to this report. after doing so click next.
now add only the field you wish to display on this table (i.e. Name). Click Next and now you can either finish or click next to the end.
Up until now you have created the first section wich will show only the names!
In order to show other columns, one under the other, you need to add more sections.
Right click the Gray Title named "Section 3 (Details)" and choose insert section below.
Now do the same to add subreport with your desired column. keep adding sections for each column you wish to display.
In order to display your report you need to do three things.
Add a CrystalReportViewer object to a Form.
By using the code, Attach your data to the report and the report to the viewer.
YourCrystalReport objReport = new YourCrystalReport();
objReport.SetDataSource(YourDataSet);
TheCrystalReportViewerObject.ReportSource = objReport;
good luck...
|
|
|
|
|
hi.......
u can use Crystal Report Item Here....
|
|
|
|
|
When typing in the method during writing the code, I noticed that Visual Studio display the description of the method on what it does. I know I found info somewhere in the past but can't find it!
How do I do that on my code so it would be easier for other developer to know what these methods are for. It'll be useful for the method overloading.
For example, when you type as follows:
MessageBox.Show(
you'll get the message saying from the tip as follows:
1 of 21 DialogResult MessageBox.Show (string text)
text: The text to display in the message box.
|
|
|
|
|
type '///' before the method and it will autotype a summary
i.e.
void DoStuff(string s)
{
}
|
|
|
|
|
THANKS! That's the answer I wanted! That's even better than the info I found in the past (manually doing the tips via xml).
Now I see why the sample codes elsewhere use /// stuff. I had no idea why coders use 3 slashes.
THANKS A HEAP! That's a new lesson I've learned today.
|
|
|
|
|
No Probs , took me a while before i learnt that too, is very useful thou
|
|
|
|
|
// Is standard single line comment
/// is standard single line xml comments
/*
* Is standard multiple line comments
*/
/**
* Is multiple line xml comments
*/
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
// Is a lazy-a$$ comment, only weak developers use it
/// Is a lazy-a$$ XML comment, only weak developers use it
/*
* Is a proper comment
*/
/**
* Is a proper XML comment
*/
|
|
|
|
|
It also gets used to provide the documentation you see in CHM files. If you have this before a method, choose the documentation options in your project you can produce a documentation file that you can use to create a help file from (using a utility like Sandcastle).
|
|
|
|
|
Cool - I didn't know that. Nice tip Pete
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Its a nice feature of .NET...
thnks sir.....
|
|
|
|
|
I am not sure if it's even possible to do this but I am trying to print out a list of various data but I don't want to put a datagridview in the form. So my question is this. Is there someway that I can build a string to skip to a certain point like something the tab might do so I could have what would look like columns?
|
|
|
|
|
Ignoring the fact that you haven't mentioned any details regarding how the string is to be processed (do you want to select specific parts of it?), I assume that the "certain point" that you want to skip would be likely to be different from string to string, so...
You could create an object that accepts a string in the constructor call, and then implement an override of the ToString() method that accepts an enum (again, one that you define) that can change the way the string is processed.
Or you could simply write a method that processes the string according to the enum value passed as a parameter.
It's almost impossible to provide relevant advice with so little to go on.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
honestly I don't really know.
First of all this is for my programming project for my .net course so that should tell you how new I am.
I basically have a list of books, but for each book there is a name, publisher, unit cost, copies ordered, and total cost. I must print the list out, but I want all the items to be lined up so it don't just look messy. I could go about it another way if you have a suggestion, I just don't know.
|
|
|
|