|
Let me give you some source code. Check back friday mid day or so.
|
|
|
|
|
Okay, here is some sample code. Sorry it's not real orderly but I just don't have time to make it real nice. I think you'll get the idea though. this code will populate a datagrid with three columns times x rows (just an exmaple, you could have as many columns as you like) from a mock of
what I think your API looks like.
Here is the form
---------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace SampleOfIList {
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form {
private System.Windows.Forms.DataGrid dataGrid1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1() {
InitializeComponent();
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing ) {
if( disposing ) {
if (components != null) {
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(640, 160);
this.dataGrid1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(656, 197);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main() {
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e) {
dataGrid1.DataSource = new MyIListImpl(new SomeAPI());
// to-do:
// use table column styles to set the order of the columns or else they are
// kind of random.
}
}
}
-------------------------------------------------------------------------------------
here is the sample API (hopefully similar to yours)
using System;
namespace SampleOfIList {
///
/// Just a little mock API with some test data stuffed in. Hopefully not
/// too different from yours but you should get the idea anyway.
///
public class SomeAPI {
// Some place to put mock data
private string[,] internalList;
///
/// ctor and stuff some dummy data in there for illustration only.
/// We'll make it 3x3 for demo purposes.
///
public SomeAPI() {
internalList = new string[3,3];
internalList[0,0] = "r0c0";
internalList[0,1] = "r0c1";
internalList[0,2] = "r0c2";
internalList[1,0] = "r1c0";
internalList[1,1] = "r1c1";
internalList[1,2] = "r1c2";
internalList[2,0] = "r2c0";
internalList[2,1] = "r2c1";
internalList[2,2] = "r2c2";
}
///
/// This is how the outside world can get at our mock data. Similar to your
/// example API.
///
/// <param name="row" />
/// <param name="column" />
/// <returns>
public string GetData(int row,int column) {
return internalList[row,column];
}
///
/// How many rows in the mock data.
///
public int numRows {
get {
return internalList.GetUpperBound(0)+1;
}
}
}
}
-------------------------------------------------------------------------------------------
here is the IList impl
using System;
using System.Collections;
using System.Data;
namespace SampleOfIList {
///
/// An intermediate row object so the grid can deal with it.
///
public struct Row {
public Row(string s1,string s2,string s3) {
c1 = s1;
c2 = s2;
c3 = s3;
}
public string COL_0 {
get { return c1; }
set { c1 = value; }
}
public string COL_1 {
get { return c2; }
set { c2 = value; }
}
public string COL_2 {
get { return c3; }
set { c3 = value; }
}
private string c1;
private string c2;
private string c3;
}
///
/// Implemented the hard way just for illustration, but this is an IList object
/// which supplies the datagrid with data. Just set the DataGrid.DataSoruce member
/// and away it goes.
///
public class MyIListImpl : IList {
private SomeAPI api = null;
public MyIListImpl(SomeAPI api) {
this.api = api;
}
void ICollection.CopyTo(Array arr,int index) {
throw new ArgumentException("CopyTo - Not implemented");
}
int ICollection.Count {
get {
return api.numRows;
}
}
bool ICollection.IsSynchronized {
get {
throw new ArgumentException("IsSynchronized - Not implemented");
}
}
object ICollection.SyncRoot {
get {
throw new ArgumentException("SyncRoot - Not implemented");
}
}
IEnumerator IEnumerable.GetEnumerator() {
throw new ArgumentException("GetEnumerator - Not implemented");
}
int IList.Add(object obj) {
throw new ArgumentException("Add - Not implemented");
}
void IList.Clear() {
throw new ArgumentException("Clear - Not implemented");
}
bool IList.Contains(object o) {
throw new ArgumentException("Contains - Not implemented");
}
int IList.IndexOf(object o) {
throw new ArgumentException("IndexOf - Not implemented");
}
void IList.Insert(int ix,object o) {
throw new ArgumentException("Insert - Not implemented");
}
bool IList.IsFixedSize {
get {
return true;
}
}
bool IList.IsReadOnly {
get {
return true;
}
}
void IList.Remove(object o) {
throw new ArgumentException("Remove - Not implemented");
}
void IList.RemoveAt(int ix) {
throw new ArgumentException("RemoveAt - Not implemented");
}
///
/// Here is the meat of the thing!
///
object IList.this[int ix] {
get {
Row row = new Row(api.GetData(ix,0),api.GetData(ix,1),api.GetData(ix,2));
return row;
}
set {
throw new ArgumentException("Indexer//Set - Not implemented");
}
}
}
}
--------------------------------------------------------------------------------------
hope that helps.
|
|
|
|
|
I was interested in how to accomplish this:
Say I have a textbox on form1.cs. I would like to print messages into that textbox from other class files such as work.cs
I am sure this is very simple and I am an idiot hehehehe
Can someone help me out?
|
|
|
|
|
Just make a public property in the other class for the text of the text box, and within it you will be able to get the value of it like :
class Work<br />
{<br />
TextBox t = new TextBox();<br />
public string TextT<br />
{<br />
get{return this.t.Text;}<br />
}<br />
}<br />
class form1<br />
{<br />
TextBox holder = new TextBox();<br />
holder.Text = Work.TextT;<br />
<br />
}<br />
But this must be have the same namespace or in the same directory ,or at least make a reference to the dll that contains that class Work .
|
|
|
|
|
Thanks for the reply!
I have attached a zip with a sample project which (I think) illustrates my problem.
If you have some time to spare, could you take a look at it?
Thanks and sorry for my pretty rookie problems...
http://www.djnokturnal.com/downloads/TextBoxes.zip[^]
|
|
|
|
|
Hello dear all
i have very big problem
i have a exe that exe will generate from C# windows application i want to use these exe method to another project of C# windows application
when i want to use this exe method from "Add reference" then it will give on error Message that is
"Converting the type library to .NEt Assembly failed type library was export from a CLR assembly and can not be re-imported as a CLR Assembly"
but i have used this type library in VB6.0 project
so how we can use this type library in .NET project Application
Please Help ME
|
|
|
|
|
The only way to think is to make that exe dll as you will move your code to a control library project and add a reference to it from your exe and in youe exe make an instance of the class that is in the dll ,,so..
as this you can use it in any number of exe ,by just instantiating this class that you want to be in the exe ,from the dll.
|
|
|
|
|
thanks for reply
but i am not getting your point basically you wnat to say that we create exe as Dll but my question is how we can use exe as Dll please give the sussion how we can use exe as a dll in other C# project
|
|
|
|
|
You can go into the Project --> Properties of the application that you want to use as a reference and change the type to Class Library (from Windows Application). This will cause a dll to be generated from the Build process. You can then include this in your other projects......
|
|
|
|
|
yeah ,do as he said and then youe exe code will be in the dll as (for example-MyForm-) then you can create another new windows application and add your dll as a reference to it from the solution explorer and then,
in this new windows apllication do :
MyForm form1 = new MyForm();<br />
form1.Show();<br />
Application.Run(new MyForm());
and you can do this in any other windows application ,Hope this helps .
|
|
|
|
|
Ok.. here's my problem.. I need to send allot of data from my client to the server and viceversa..
My aproach is to use xml tags in a way that the data set can understand and load..
I worked for a while.. but whenever I get a transmision I need to save the data and load the dataset from the file..
The problem is that the datagrid closes down and I can't do anything more ...
My question :
1.Is there a way of sending files ( .xml, .rar, .exe, etc..) over the network using Sockets or TcpClients?
2. What's the best way to manage huge amounts of data ?
3. How to get the dataset not to crash ?
If the answer should contain a project it would be much aprecieted ...
Lazar Mihai
Highschool student
|
|
|
|
|
Hi Lazar, when you are sending large amounts of data over a network, your best bet is to use the most compact form available, xml would be a good choice for a smaller load, but if there is truely a lot of data, then you might consider sending it in binary form and yes, you can and probably should use .NET sockets. These are pretty easy to use with a little practice but might give you a little frustration at first. Don't give up on them though because they are the very best way to move large pieces of data across the network. For #2, I would probably spool the data into and out of an xml DataTable so the grid can see them directly. Look at the DataTable object in .NET! Create one and play around with the Grid connected to it, it's pretty easy once you get the hang of it. As far as #3 is concerned, not enough detail for me to say, sorry, but I will say it is most likely not a bug in the grid as I've used it extensively for some time without problems unless I was doing something wrong.
Good luck on your project.
|
|
|
|
|
I know how to use the sockets and I know how to use a datagrid and datatables ... I'm going to try the binary sending .. and see what happens.. as for the datagrid the reason it's crashing is that I save the xml data into a file that I read it whith the dataset's ReadXml(..) method and it has to load the entire dataTable at once ...
My best quess for the crashing is that .. there can't be any other explanasion more plausable..
Thanks.. if you have any other suggestion fell free to send them ...
P.S : I'm using TcpClient and a network class made by me.. which has some events that tell me when I recieve a message or when I'm cur off from the server !
Lazar Mihai
Highschool student
|
|
|
|
|
How would I go about creating an add-in for vs.net that adds to the context menus of server explorer?
E.G. An new option when you right click on a table in a mssql db in the server explorer.
Any suggestions / useful links?
|
|
|
|
|
Hi everyone! As I'm new here I'd like to say hello!
I have this problem - I created a control, and added properties there. When I use the DefaultValue attribute everything goes nice and smooth when I provide strings, int null, enums and so on. But when I want to give a default color:
<br />
[Category("Appearance"), DefaultValue(Color.Black)]<br />
the compiler says: An attribute argument must be a constant expression, typeof expression or array creation expression. But there are default colors for standard controls. What should I do with it?
Another thing: when I write:
<br />
public static const string STH = "Something";<br />
I got an error.
Pls help me with those!
|
|
|
|
|
The static modifier is not allowed in a constant declaration and also not needed, cause constants automatically belong to the type where they are declared.
www.troschuetz.de
|
|
|
|
|
For the first problem, use DefaultValueAttributes overloaded constructor as follows.
[DefaultValue(typeof(Color),"Black")]
For the second one, you can declare a variable as static and const both. it should be either static or const.
You can use public static readonly string STH = "Something"; instead
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Hello,
I am developing an application for a stock control system. I am using a datagrid and the customer wants a combo box in one of the columns, to make selection easier.
I my database l have 2 tables, customer and parts. Relationship a customer can order many parts. So the grid will display all the different parts. and the user will click on the customer column and select the customer who wants this part.
example. PartID, Name, price, quantity, customer are the column headers in the datagrid.
Thanks very much for your help in advance,
Steve
|
|
|
|
|
That is quite not easy just inherit from DataGridColumnStyle and just make on it combobox and make it's bounds as this control and override all these methods: Commet(),Edit(),Abort().
|
|
|
|
|
Brief: Iam working on an enhancement for our product. This requires integration with Document Management System. The DMS(Document Managemen System) works on Citrix environment, which has Server and Client components, which our product needs to use for communication between citrix server(where our application is published) and client (where we run our application from, using seamless citrix connection).
We are supposed to encryt some data on the citrix server and pass it to citrix client, for which we have developed an encryption component. This component uses RSACrytoServiceProvider's encryption using certificates.
The following is the code for encryption:
//Convert the data that we wish to encrypt into a byte array
byte bytDataToEncrypt[] = ASCIIEncoding.ASCII.GetBytes(strDataToEncrypt);
// Get the RSA parameters from the certificate - since this we
// are encrypting using the public keys in the certificate
// we pass the false parameter so that the private keys are not exported
RSAParameters objPublicKey = bjCertificate.PublicKey.ExportParameters(false);
// create the crypto service to use for the encryption
RSACryptoServiceProvider objRSA = new RSACryptoServiceProvider();
// Use the previously obtained RSA parameters
objRSA.ImportParameters (objPublicKey); (where objPublicKey is the encrypting certificate object)
// perform the encryption
byte bytEncryptedData [] = objRSA.Encrypt(bytDataToEncrypt, false);
//If Encrypted Data is not null
string strEncryptedData;
if(bytEncryptedData != null)
//Convert the encrypted byte data to hex
strEncryptedData = ConvertByteToHex(bytEncryptedData);
else
strEncryptedData = string.Empty;
return strEncryptedData;
The Encryption component successfully finds the encryption certificate. But while creating a RSACryptoServiceProvider object I get the following error.
"Crypto API cryptographic service provider (CSP) for this implementation could not be acquired".
After finding an article for the above error in web, I have made the following changes in the above code as follows:
// Create the crypto service to use for the encryption
CspParameters CSPParam = new CspParameters();
CSPParam.Flags = CspProviderFlags.UseMachineKeyStore;
objRSA = new RSACryptoServiceProvider(CSPParam);
Also gave “Full Control” permissions to the following path for “ANONYMOUS LOGON” user on Citrix server machine:
“C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys”
I then got the following error:
“Access Denied”
Later I gave “full control” permissions to “EVERYONE” user, to the above path.
Then the encryption part worked fine. But when this encrypted data is passed from the Citrix server by the DMS server component to Citrix client. the DMS client component on Citrix client is not able to decrypt the data. It gives the following error:
"Error decrypting: The total input data is not a multiple of block size. The block size is: 128"
I guess that there might be some problem with access rights for “ANONYMOUS LOGON” user or usage of CspParameters. I also tried to know more about the error by using the File and Registry Monitoring tools available at www.sysinternals.com. But I am not able to find out where the exact problem lies.
Please HELP !
Thanx in advance
|
|
|
|
|
hi,
i want to add checkboxes to combobox what shoud i do?
thanks
|
|
|
|
|
inherit from combobox and in it's listbox add control of checkbox kind.
|
|
|
|
|
Can Any one Help me Abt Dynamic(Runtime) Dll, how to implement it in C#.Net. When ever i am compiling my project all the dll should not be compiled. It means that a particular dll has to be loaded when ever i had called, else it should not.
Shashidhar.
|
|
|
|
|
Sorry I'm not completely understanding, do you want to compile the dll conditionally, only when you want, or do you mean that the application should only load the DLL when it is needed (which is the decault behavior in .NET anyway) ?
|
|
|
|
|
My requirement is to have multiple .Net dlls, which has similar functionalities exposed (so that I can expose functions of same signature). One of these dlls should be loaded at runtime based on user's selection of dll file name. In effect I need to support my application in such a way that, even after initial deployment, I will be able to deploy additional dlls (additional dlls alone will be separately deployed), which user can select at runtime.
Shashidhar
|
|
|
|