|
Yes, just check the DataTable to see if it has any rows.
<br />
DataTable dt = new DataTable();<br />
if(dt.Rows.Count > 0)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
thankx
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
I am nor sure this is the best place to post this but here goes.
I have a tool (in this case Crystal Reports) that exports to RTF format. My problem is that I now need to combine existing rtf files into 1 rtf file. Does any know of a project that does this. I posted my question here since I use C#.
|
|
|
|
|
I would like to know how to implement generic functions.
I have a few classes: CdRecord, BookRecord, Record, and RecordManager.
CdRecord inherits from Record. BookRecord inherits from Record.
In my RecordManager class, I have a bunch of functions.
Two of the functions in RecordManager read info from a table in an SQL DB.
rough code:
using...
namespace MyProject
{
class RecordManager
{
List<cdrecord> CDrecords = new List<cdrecord>();
List<bookrecord> BOOKrecords = new List<bookrecord>();
public void readBooks()
{
// connect to DB
// fill BOOKrecords with entries from table
}
public void readCds()
{
// connect to DB
// fill CDrecords with entries from table
}
}
}
Now, once I've filled CDrecords and BOOKrecords, I need a function that will split them, and re-arrange the order of the records. I realise I can make one function that takes a List<bookrecord> parameter and one function that takes a List<cdrecord> parameter, but I'd prefer to have one function be able to handle them both. I also know that I can just send an extra parameter (int i for example) that indicates what type i am working with (if i == 1, BookRecord list, etc). However, I don't like this method either. In the future, I may end up with many more classes that inherit from Record, that I'll have lists of that need to be split, and I don't want to have a function for each type because I may end up with 20 redundant functions. Similarly, I don't want to send an extra parameter because of readability (if i == 1, if i == 2, .... if i == 20). How do I make one function that is able to take a paramater of type List<t> where T can be CdRecord or BookRecord?
I have tried the following, and it does not work:
public void SplitRecords<t>(List<t> records, int start, int end)
{
//some code
for(int i = start; i <= end; i++)
{
//some code
records[i].memberFunction();
//some code
}
}
The reason it doesn't work is because "memberFunction()" is a function of Record (which is inherited by BookRecord and CdRecord) but "T" does not have a definition for "memberFunction()"
How do I correct this? Could I be experiencing problems because I am trying to use classes I wrote with generics, rather than int/short/etc.?
Thanks in advance for any assistance!
|
|
|
|
|
You can limit what T can be, and so you'll have access to the methods of the base types from the T instance.
where T : Record is what you need on the end of your generic class definition.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am trying to call the event OnHelpButtonClicked.
I am unsure of how to get it to work. I am using the following code:
private void button1_Click(object sender, EventArgs e)
{
CancelEventArgs Arg1 = new CancelEventArgs();
Arg1.Cancel = false;
OnHelpButtonClicked(Arg1);
}
|
|
|
|
|
Hello,
The question is not clear at all, I think.
But if you have a button on your form, which is named HelpButton, you could use the PerformClick[^] method of the Button.
HelpButton.PerformClick();
If you mean the Help funktionality "F1", you could use SendKeys.Send[^]
SendKeys.Send("{F1}");
Hope it helps!
All the best,
Martin
|
|
|
|
|
I don't think I have made myself clear. I am trying to use the Help Button that can be added to the title bar of a window, the problem with using it in the title bar of the window is that you have to remove Max and Min window (as seen here http://davidkean.net/images/helpwindow.jpg).
What I would like to do is link this Help Button to a button that I have created on my form. Thus the following code.
CancelEventArgs Arg1 = new CancelEventArgs();
Arg1.Cancel = false;
OnHelpButtonClicked(Arg1);
The problem is when I call this nothing happens, I know it is getting into the OnHelpButtonClicked function (as I override the function) but it does nothing when it enters the base.OnHelpButtonClicked.
Thanks for the help.
PS I tried the HelpButton.PerformClick(); and it does not have it
|
|
|
|
|
Just add a little more information into this, I now am starting to think that I am not overriding the right function as when I override the OnHelpButtonClicked and remove the base class it still works.
|
|
|
|
|
Ok,
Now I understand your problem.
I tried it with SendKeys, and it opens the help!
All the best,
Martin
|
|
|
|
|
I have a c#.net project that I am working on. I made a gridview object and an XMLdatasource object and I bound the xml data to the grid view. So the gridview shows all the States from the XML File.
I am trying to add a simple search on this data with a textbox. This textbox is calling a textchanged function on each keystoke. Inside this textchange function i was trying to dynamically search the XML data and display only the States that contain the same as the textbox or start with or end with the text that is in the text box.
I dont know how i can dynamically update the gridview. Any advice will be helpful.
Craig <state name="Tennessee">
<state name="Texas">
<state name="Utah">
<state name="Vermont">
<state name="Virgin Islands">
<state name="Virginia">
<state name="Washington">
<state name="West Virginia">
<state name="Wisconsin">
<state name="Wyoming">
I dont know how i can dynamically update the gridview. Any advice will be helpful.
Craig
|
|
|
|
|
Are you using Xpath to retrieve the filtered nodes?
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
In the Win32 API, it's possible to easily encrypt data that can only be decrypted by the same user on the same machine. The data cannot be shared among different installations of Windows, or other users on the same installation.
The function that does this is CryptProtectData() .
Does the .NET Framework offer a way to place the same restrictions on encrypted data?
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
With p/invoke, you can call any Win32 API you like. Try www.pinvoke.net[^] to see if they have the signature for that method.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, thank you. That is a viable option, but are you saying that there is no comparable method in .NET, or that you are not aware of one?
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
I really don't know.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
have you considered using the Enterprise Library Crytopgraphy Application Block.
From memory, it does generate a key based on the User's credentials. Then this key can be used to decrpty or encrypt information as desired.
Take a look at this article: http://davidhayden.com/blog/dave/archive/2006/03/04/2874.aspx
|
|
|
|
|
Thanks for the reply. I'll take a look!
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
I have a program that is semitransparent and is topmost. If a different program has focus, the keyboard messages reach it (the other program) just fine, but my topmost form intercepts mouse input (understandably so). How can I make my program take all mouse input and resend it through Windows's message pool so that it's as if my program wasn't there? I want to be able to function in the other active applications as if my program wasn't there (wasn't topmost).
The reason it has to be topmost is because it has a duplicate of the user's background image on it. Being semitransparent, it gives the effect that, instead, all of the other programs are semitransparent (the ultimate goal), so that the user can still faintly see their wallpaper "behind" their programs (because I don't know how to forcefully reduce all other programs' opacity).
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
My shameless plug[^] on click-through forms.
You can't force another app's window to be opaque. You have no control over how another app paints it's windows. On top of that, what you have to do to the window to support opacity could very well make the other app's painting code crash.
|
|
|
|
|
I understand that I can't alter how another window paints itself. That's why I needed a click-through-able window.
Your shameless plug is exactly what I needed! (well... after manually converting the VB to C#) However, it wasn't working exactly 100%. I took out the lines that changed [myform].Opacity and it seems to be working just fine now (using SetLayeredWindowAttributes instead of Form.Opacity).
Thank you!
I now have a wallpaper that seems to "show through" all of my windows (as if all of my windows were semitransparent)!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hello everyone,
I have a DataGridView controll which is populated by a table from a remote database. One of the Columns contains images which I am using the following line of code to access the images in the DataGridView.
System.Drawing.Image itemOriginalImage = (Image)dataGridView1.Rows[ItemRowIndex0].Cells["item_image"].FormattedValue;<br />
I wish to remove the DataGridView and replace it with a DataTable. I was wondering how I can access the image column in the DataTable?
I am using this code but I am unable to set the format right.
System.Drawing.Image itemOriginalImage = (Image)myTable.Rows[ItemRowIndex0].ItemArray.GetValue(6).<br />
I get the following error for the above line of code. "Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'."
Can someone be kind enough to tell me how I can access the image in my DataTable?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Use
System.Drawing.Image _image = System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])myTable.Rows[ItemRowIndex0].ItemArray.GetValue(6)) );
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I have a string strA = "12 MyAddress"
strB = "Your Name"
I want to get the first char of string and want to know weather it is integer between 1-9 or char between A-B.
How can I do that.
seema
|
|
|
|
|
The string class provides a handy little Substring function. You can cast it to a char, and the char class provides functions like IsDigit to help. Have a look at the documentation for these classes to get a clear idea of exactly what you need to do.
Deja View - the feeling that you've seen this post before.
|
|
|
|