|
|
I have a datagridview which allows users to enter new values for each column. But what I would really like is to prevent the user to add value to other columns if column MSISDN is still empty. which means, user must FIRST add MSISDN value before filling up the rest.
Is there anyway where I can prevent the cursor or prevent setting focus to cell before anything else.
THANKs!!!!
|
|
|
|
|
simply use "CellValidating" event for other columns.
in this event check whether if your MSISDN column is empty then set cancel to true.
|
|
|
|
|
|
Hey howzit?
I would like to import outlook contacts in my C# application. I have found a handy application on the code project: http://www.codeproject.com/com/outlookcontacts.asp?df=100&forumid=14626&select=1409933&msg=1409933 but it uses C++ and I do not want to use this code...I heard there is code in .NET for doing this...can anyone please help me?
Regards,
|
|
|
|
|
Hi,
I have a problem in C#, which in C++ i would solve within seconds using pointers/references
But how to solve this in C#
I will try to explain my problem with an example:
I have two classes Data & Formatter
public class Data
{
public string strText;
Formatter formatProtocol;
public Data()
{
formatProtocol = new Formatter();
}
}
public class Formatter
{
public Formatter() {}
void FormatNow()
{
}
}
How do I let the Formatter change the strText member ???
How should i solve this if it wasn't a string but a ValueType ?
codito ergo sum
-- modified at 4:02 Thursday 16th March, 2006
|
|
|
|
|
Please post into the C++ forum. This is the C# forum.
No hurries, no worries.
|
|
|
|
|
I know,
I need to know how to solve this problem in C#
codito ergo sum
|
|
|
|
|
OK, my apologies,
you can create a getter/setter method (more Java based) or a property (C# based)
This is exactly the concept of incapsulation.
so to get to a private member of your class you can do this:
C# based:
public string AStringName{<br />
get{<br />
return theprivatemember;<br />
}<br />
set{<br />
theprivatemember = value;<br />
}<br />
}
This allows you to check if value has correct value (according to your needs) before actually setting them.
eg.:
classinstance.AStringName = "Hello CodeProject!";
will result in the theprivatemember = "Hello CodeProject!"
You can do the same for int, arrays and even objects.
good luck!
No hurries, no worries.
|
|
|
|
|
No apologie needed (no offense taken )
this solves the private/protected issue of my problem but i still need to pass and
store a reference to the Parent object.
See my reply[^] on the solution J4amieC of to understand what i mean.
I have used this simple example to state what I need, I know that the suggested solution works perfect in this case, but the real object model is more complex then this.
codito ergo sum
|
|
|
|
|
If you used to solve it in seconds using references using C++, why cant you solve it in seconds using references in C# AM I missing something?
public class Data
{
public string strText;
Formatter formatProtocol;
public Data()
{
formatProtocol = new Formatter(this);
}
}
public class Formatter
{
private Data toFormat
public Formatter(Data theData)
{
this.toFormat = theData
}
void FormatNow()
{
this.toFormat.strData = "Hello reference";
}
}
|
|
|
|
|
Thanks for the response.
I see few problems with this approach.
1. The Formatter has to know the structure of the Data object this will lead to difficulties when I need to support multiple non-inherented classes Data1, Data2;
2. This alsoo breaks security when the modifier of the member is protected or private, here it needs to be public. Or can I make the two class friend of each other.
3. I'm not sure about this one, but isn't there a Garbage collection issue. I mean both objects point to each other. But I can only 'delete' one (Set the Data object = null)
In c++ i'm used to pass only the data that the other class needs to know/change.
If it only was a function I could pass the string with the ref or out token.
But i need to store it for later processing.
I'm really stuck here
codito ergo sum
|
|
|
|
|
BadKarma wrote: The Formatter has to know the structure of the Data object
Isnt this true of anything termed a "formatter"? If I am to format a word document, I have to have the word document right? I cant format it it i cant see it!
BadKarma wrote: This alsoo breaks security when the modifier of the member is protected or private, here it needs to be public. Or can I make the two class friend of each other.
Make them internal if you like, or a better solution is for all data structures to implement an interface and take that interface in the ctor of the formatter.
BadKarma wrote: I'm not sure about this one, but isn't there a Garbage collection issue. I mean both objects point to each other. But I can only 'delete' one (Set the Data object = null)
No issue, it will all be taken care of for you by the runtime.
|
|
|
|
|
I know your pain, I was experience C/C++ withdrwals too. Here's my take: you don't need any pointers in managed safe code. In system code (i.e. unmanaged you can still use them). Now with that said most applications are more easily maintained and written if they leverage the C# managed classes.
You still have Ref and plus a new Qualifier call Out. But instead of operating on addresses, all C# logic is based on arrays and indices. So I could have an 100 item array of int called myList. If I call a funtion called AddTheValues it might look like this:
<br />
public long AddTheValues( int[] numbers )<br />
{<br />
long total = 0;<br />
<br />
for ( int i=0; i < numbers.Length; ++i )<br />
total += numbers[i];<br />
<br />
return total;<br />
}<br />
Out is sort of like a built in malloc or new that a function returns thru the parameter list instead of as a return value. Good fpr special allocator type code.
<br />
public void NextValueList( out int[] num, int size )<br />
{<br />
num = new int[size];<br />
}<br />
Ref is used when like in C++ we are concerned about operating the SAME structure. In C# you normally don'd have to clean up (i.e. free) new'd elements. This is true for the general case. BUT if you have hairy I/O classes then there is a destructor equiavlent called IDisposable. Basically you derive your C# class from this Interface and it provides the Dispose() method you can customize to clean up.
Good Luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
Hello!
I have a very specific question and that is about how to inherit a visual
control for example the control System.Windows.Forms.TextBox without causing
the environment to delete the control when there are some compile errors.
It's the same problem with any visual control that you inherit. The control
is deleted as soon as you use the View Designer when there is compile error.
It's very easy to reproduce my problem. You can do it in this way.
1. Create a class called ExtTextBox like this. In my example here I have
removed the namespace. But if you include namespace make sure you have
access to it.
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}
As you can see this class ExtTextBox inherit from the ordinary components
System.Windows.Forms.TextBox in the .NET framework
2. Create a windows form with any name. The default is Form1
3. Use the View Designer and drag the control TextBox into the window form.
My control was called textBox1
4. Because I want the control textBox1 to be an instance of ExtTextBox I
have to edit the InitializeComponent() I don't have any other idea.
Here is an extract from my windows form called Form1.
Only the interesting rows is written. Two rows is important here.
First saying that control textBox1 is of type ExtTextBox.
Second edit the InitializeComponent and say that textBox1 is an instance of
ExtTextBox.
public class Form1 : Form
{
private ExtTextBox textBox1;
...
...
...
Private void InitializeComponent()
{
this.textBox1= new ExtTextBox();
...
...
...
}
}
5 Compile. Hopefully you don't get any compile errors. When you run the
application only the textBox is being displayed. The problem might start
even here. If you get any compile error and you use the View Designer the
control named textBox1 is being deleted.
6 If you don't get any compile error make a change so you get a compile
error and then use the View Designer the control named textBox1 is being
deleted.
7 Now to my question. I can't use controls that being deleted automatically
when I get compile error as soon as I use the View Designer.
8. If I want to use inheritance on visual control how do I do. I just can't
have it as it is now.
9 I just can't use inheritance in the way I do now.
10. I hope that you have a good suggestion how I should use inheritance on
visual control to avoid this kind of problems.
Additional information: I have a project containing
several forms and some code class files. One file in the project is a code
class file which contains this ExtTextBox in this way.
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}
When you build the project(assemby) and you get some compile error and you
then use the View Designer on a form containing this inherited control the
control will be deleted.
I have also noted that you can avoid that the control is being deleted but
it's a very annoying way to do it on.
Before you build the project(assembly) you click on Windows->Close All
documents.
Then you build and you get some compile error and you can still use the View
Designer and see the control.
I just can't use that solution having to close all the documents every time
before I build the project.
When I use inheritance I want to extend for example the TextBox class by
additional functionality.
If I create a userControl(see below) for example like this. I can't extent
the class TextBox with additional functionality because the control is a
member in the UserControl class. I can extend the functionality of class
UserControl1 but that is not what I want.
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.TextBox textBox1;
...
...
...
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox():
...
...
...
}
}
So the main question is how do I do if I want to inherit(extend) a visual control class for example TextBox without having the TextBox control to be deleted as soon as I use View Designer.
Is it possible that my problem is a kind of bug in the .NET framework.
I use VS 2003.
//Tony
|
|
|
|
|
How can i remove a datarow from a dataset after validating some new added records without traversing the whole datarow collection. If i get the dataset by using GetChanges(DataRowState.Added) method it returns a new dataset hence if we enumerate on it. It doed not allow to delete in actual dataset.
<pre>
DataSet dstAdded=dst.GetChanges(DataRowState.Added)
foreach(DataRow dr in dstAdded.Tables[0].Rows)
// Some validation ...
dstAdded.Remove(dr) // Removes from Added Dataset
dst.Remove(dr) // Gives an error DataRow does not belong to dataset
</pre>
|
|
|
|
|
I am developing a client server application. For to do that I opend the port 1234 in two machines and send some data to destination.
UdpClient udpClient = new UdpClient();
udpClient.Connect(123.123.123.123,1234);
Byte[] sendBytes = Encoding.ASCII.GetBytes("TEST");
udpClient.Send(sendBytes,sendBytes.Length);
But I am working in a LAN. Means my IP address is local to this LAN. I want to communicate to the machine in a different network. How can I get the actual IP address ?. Eg : my ip address is 192.168.1.16 ( if give the command ipconfig in command window). Its local to my network. But my IP in the global status is our router IP. The how can I identify each computer from another network ?. How yahoo messanger in identifying each computer in the lan ?
any help Please ...
Thanks in advance
Cheers
Jijo
|
|
|
|
|
To get your externnal IP adress you can go to one of the many sites that provide this information.
If you want to know how the router keeps track of the traffic, read up on NAT[^].
---
b { font-weight: normal; }
|
|
|
|
|
|
I am working at a project about using IE printing components. So the IHTMLDocument2 interface was adopted by me. But i need to user IPersistStreamInit interface of IHTMLDocument2. Because the IPersistStreamInit is in System.Windows.Forms.UnsafeNativeMethods, which is declared as internal, I can't declare any variables with data type of IPersistStreamInit. Recently I have learned about the reflector, but this seems not feasible. Who can tell me how to do this? Thanks very much.
|
|
|
|
|
Hai Folks.......
I am using Nullable.Wrap() function with beta version .Now i am upgrade to new release .I dont why they removed this function from Nullable class .OK anybody know how can i change my current code to work properly ..
With Regards & Thanks,
Kiran Kumar Singani
|
|
|
|
|
When i use Keypress to catch Keys in TextBox. When it run, i want to copy A text from word, notepad....But i can not use Right click/paste on it. I have Catch "Ctrl+V" it is ok.
Now i want to Fix it.
Please help me!
superdragon
|
|
|
|
|
i'm sorry, i have some misktakes with textbox Event changevalue. That is reason i did not do what i want.
superdragon
|
|
|
|
|
why my search function in cystal report cannot work when i type a string, the result always display "end of search"
angela
|
|
|
|
|
Who can help me this problem with C# program?
dny
|
|
|
|