Ok then .. could you provide the code, that you use to run server and a client's part, when you're making attempt to connect?
kvprajapati commented: Greate Explanation. +9
ddanbe commented: Nice suggestion:) +5
Ok then .. could you provide the code, that you use to run server and a client's part, when you're making attempt to connect?
Ok, let's start from the beggining ...
The task is make a WPF application. What we usually expect from server - is performance. From client we usually expect usability, attractiveness, etc. (also performance, but less than from server). So it would be logical to make a server part of an application as Console application (as adatapost mentioned). And the client part would be a WPF application. So let's describe the basic behaviour for both parts:
Server:
Client:
So now you should make 2 applications (the Console one and WPF one for the server and client respectively). I would suggest you to create them within one solution to ease the control of them.
Ok, now we have basic algorythm and 2 empty projects created. Now - closer to code .. I've changed a bit the client and server part .. Let's start from server:
static void Main(string[] args)
{
//The IP adress of computer, where server is running
IPAddress ipAd = IPAddress.Parse("127.0.0.1");
//Initialize listener on given IP and port
TcpListener myList = new TcpListener(ipAd, 8001);
//Start Listening at the specified port
myList.Start();
Console.WriteLine("The server is running at port 8001...");
Console.WriteLine("The local End point is :" + myList.LocalEndpoint);
//Endless …
Hello,
I can't see the problem yet, but I got one thing to say - you don't close neither the connection to your client, nor the NetworkStream
, that you're working with.
This thingy can bring some troubles :)
Let me know if it solves the problem .. if not - we'll try to find another solution.
Hello, you have interesting problem ... let's see:
Does this make the slightest bit of sense?
Well, that depends on from which view to look at this:
Now - closer to your problem. Indeed, your variant of that java piece of code look a bit strange. So we must to redesign that a bit...
Just to be sure .. are you sure, that for your case StringDatatype and NumericDatatype should have same base class? (Even in C# they derived from System.Object and System.ValueType respectively). Maybe they have more differences, than commons? .. Or maybe just problems in an example ..
Ok, if inheritance from that base class is …
Hello,
to extract the value of your d
variable into given string, you should:
Here's what I'm talking about:
"/c \"format " + d + " /fs:ntfs"
Hello,
since interfaces doesn't have a GetType method, you can use something like this:
if (input.GetType() == typeof(Bar))
Just a thought in a loud .. are you sure that it's really needed. Maybe there's a better approach for your problem?
Hello,
unfortunatelly I have no tools to test your code right now .. but I want share some thoughts about that.
I suppose that, that might be a problem with boxing of a ref-type variable when passing it in parameters list (by the way, have you tried passing it as "ref intReturnValue", rather than as "intReturnValue"). Anyways - take at look at this discussion: C# 4.0 ‘dynamic’ doesn’t set ref/out arguments.
Hello,
just want to add my 2 cents :)
As farooqaaa said, you should test if your events are fired. If they're fired, but display still won't update, try to call Application.DoEvents Method to force events processing.
One more way achieve that functionality can be using of DataBinding
.
Hello,
Have you tried to play around IsMDIContainer
property for parent container and MDIParent
for a child one? Unfortunatelly I have no tools to test it right now, but I suppose that it should work like a charm :P
Cheers.
I think this discussion can put some light on your problem: When should the volatile keyword be used in C#?
Hello, I hope I understood you correctly ..
If you've started to talk about custom controls .. why not create a custom tab? Especially if you'll have an identical - looking tabs, I guess it would be a better way to create a sort of template. Here's an example to show what I'm talking about:
definition of a custom tab:
class CustomTab : TabPage
{
//just for example storing a link
//to newly created texbox
private TextBox _textBox;
// a property to set a text
//for textBox
public string BoxText
{
set { _textBox.Text = value; }
}
//creation of textBox on a Tab
public void addTextBox()
{
TextBox tb = new TextBox();
tb.Name = "tb" + Name;
tb.Location = new Point(10, 10);
tb.Parent = this;
this.Controls.Add(tb);
_textBox = tb;
}
}
Ok, now we've encapsulated all the "magic" of creating and setting [inline]TextBox[/inline] inside the custom Tab class. This allows us to do such thing inside of main prog:
//creating a tab
CustomTab ct = new CustomTab();
... making some setups on Tab
//adding new TabPage to our tabControl
tabControl1.TabPages.Add(ct);
//adding a TextBox to our TabPage
ct.addTextBox();
... and maybe somewhere in other part of code (or from your example - on ButtonClick event):
private void button1_Click(object sender, EventArgs e)
{
((CustomTab)tabControl1.SelectedTab).BoxText = "Hi there";
}
This is just an example to start from .. you can place creation of the TextBox inside the constructor of CustomTab, or do whatever best passes your case.
…Hello, your way is technically correct.
I just want to know .. are you new to c# or to programming at all? Just there is a better way to store data, e.g. using List<T> and structures or classes ..
P.S. Please, next time put your code in code tags :)
You're welcome!
Good luck with your project :)
Hello,
I just want to share some thoughts to consider on your problem.
About suggested ways to go:
1. Leave it as it is it works but is inefficient
I think this solution has it rights to exist for the case when your collection has small size. But it isn't true for your case, so we're moving on. It would provide faster access to your data.
2. Create a 'master' defectcollection, preload it with all the defects and reference them
Well, same as for previous case - you can freely use it, when don't have too many data.
3. Write an defect collection that loads defects as required and allows multiple release objects to reference them
I think that is a step into right direction .. using less memory and still keeping it fast.
4. Write the defectCollection as a lazy collection populated only when it is referenced
I think it's the best of suggested solutions. Since your application isn't real-time system - you freely can make your user wait few more seconds (or even milliseconds) to load requested data. Moreover, if I were you - I categorized the defects on groups .. even made some structure of them to lessen the amount of information needed to load each time (also it can help to navigate between those defects). And place all this into e.g. lazy loading tree. (It can be whatever you want .. one more example would be a paged table, which loads …
Oh, my! Might be, but wasn't good enough. How could I miss that OraLocaleInfo
? One more stupid mistake in my list :D
Thank you sooo much
Hello.
The compiler tells you that it doesn't understand what is Tree[/]. To fix the problem you should either add import for Tree
data type, or declare this data type in your makeup1 class.
Okies. Now the points of attention in the given example:
ComboBox creating ..
this.ComboBox1 = new System.Windows.Forms.ComboBox();
...
Now to be able to catch and process the events
, raised in your combobox in runtime, you should add event handler to it:
// Associate the event-handling method with the
// SelectedIndexChanged event.
this.ComboBox1.SelectedIndexChanged +=
new System.EventHandler(ComboBox1_SelectedIndexChanged);
Ok, now we have ComboBox, with event handler attached to it. Now all you have to do is implement the logic of this method, which will be raised as soon as Selected Index in your Combobox would be changed. Here's what the example gives:
private void ComboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//obtain ComboBox, which was raising this event
ComboBox comboBox = (ComboBox) sender;
// Getting selected item from it
string selectedEmployee = (string) ComboBox1.SelectedItem;
// Working with other controls on the form
TextBox1.Text = TextBox1.Text+ "\r\n" + selectedEmployee + ": "
+ count;
}
Hello.
Not sure if I've got the point .. but I'll take a shot :) What about using ComboBox..::.SelectedIndexChanged Event?
If I'm wrong, please give more details on what troubles are you facing .. e.g. you don't know, how to get value from ComboBox .. or something else.
Hello, everybody.
I had a problem while connecting to Oracle. Got messages:
ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified
And found solution for this - setting the default locale in java code:
Locale.setDefault(Locale.US);
This works just fine for me. BUT if on target machine Oracle would have other locale? Is there any chance that I can programmatically obtain the Locale, which is set for Oracle at runtime (and not connecting to it, because for connecting I should change default locale if it differs)? Or maybe there's more clear way to solve that problem (with no locale switching) ..
By the way, I use:
Oracle 10.2 XE
JDeveloper 11g
Any help would be greatly appreciated :)
:) You're welcome and good luck with your studies!
Hello.
Or use using
directive inside of target namespace:
namespace RestaurantSoftClassLib.User
{
using RestaurantSoftClassLib.Karyawan;
class User
{
Karyawan karyawan;
}
}
In your code the RestaurantSoftClassLib
is visible even without this:
using RestaurantSoftClassLib.Karyawan;
Because the User
namespace is inside RestaurantSoftClassLib
. And if you remove this using - there will be no effect. I'm not sure, but suppose that this relationships are more significant and the code, when you're trying to make a reference on RestaurantSoftClassLib.Karyawan
is just being ignored.
But since the User
is aware of RestaurantSoftClassLib
- it has no idea about Karyawan.
So if you restrict the scope of using directive to particular namespace - it would work just fine :)
Hello.
That's weird .. works fine for me when I use this:
using RestaurantSoftClassLib.Karyawan;
and then
Karyawan karyawan;
Try to remove one Karyawan
.. what's happening if you use only one?
Hello again and welcome to DaniWeb :)
Ok, let's start from error, that you get:
"Unable to cast object of type 'CSocketPacket1' to type 'CSocketPacket'."
I'm not sure if I'm right .. depends on what is CSocketPacket1
. Looks like a typo :) If it's not - is there any relationship between CSocketPacket1
and CSocketPacket
(I mean inheritance)? If not - C# doesn't support implicit conversion from user-defined types to pre-defined types.
And regarding this:
im developing a Lan chatting System...
i wnt to recieve data and accept at the same page....
its working only ig there is only two systems... 1 server n anthr 1 as client.....
Could you provide more information about problem you're facing .. and maybe some code, that gives errors or is incorrect?
Don't you love those people who obviously just joined the forum for the single purpose of asking a complicated question in a manner that makes it seem just a simple as "which way is the bathroom?"
I do .. I do :) moreover - you can see that I give my help mostly for newbies ..
Reminds me of when I first started programming. Once you get into the mindset. You look a problems completely different. And the questions you ask are much more refined. But sometimes its the difference between "Do you know were I could get some lumber and a hammer?" and "I would like one(1) free house please."
Yeah, you're right .. everything's possible. But this words made me feel a lil bit confused:
can you send the files(database files and class files) SNIP
But the only person, who can cast light on this situation is OP. Let's wait till he/she will answer .. if he/she will :)
Hello, there's a suggestion in error message:
Some errors can be fixed by rebuilding your project, while others may require code changes.
Have you tried rebuilding?
One more thing:
The type 'System.Windows.Forms.OpenFileDialog' has no field named 'file'.
Do you have such one? If no - remove the reference to it. Seems like the error lays somewhere near this field ..
Hello.
I'm not sure if this is what you're looking for, but to get array of child forms, you can use the MdiChildren
property, e.g.:
this.MdiChildren[0].BackColor = Color.Black;
//and in same manner for sub - sub child forms
this.MdiChildren[0].MdiChildren[1].BackColor = Color.Black;
You're welcome .. please, mark this thread as solved if we're done with you problem :)
Hello.
Dunno if it will suit your problem, but as an option - you could remove the header of the window. That's gonna help you to set the size to whatever you want.
Ok, let's take an example:
137*1456
We can factorize it:
137*(1000 + 400 + 50 + 6)
To see the connection, we can convert this in form like this:
137*(1*10^3 + 4*10^2 + 5*10^1 + 6*10^0)
(where ^ means powering)
So, depending on the position of the digit in the number, we can represent it in such view (see above).
so, what we have:
137*1456=137*1*10^3 + 137*4*10^2 + 137*5*10^1 + 137*6*10^0
All you have to do now - is extract algorithm from this and code it :)
Hello, just to make sure .. you have WinForms Project or Web-vased?
:) you're welcome
Sure.
Here's pretty interesting class for history handling (with example project): Navigational history (go back/forward) for WinForms controls
It has basic functionality, but you can widen it any time you want :)
:) you're welcome. Good luck with your project!
Hello.
I have a doubt about if there a custom class or something similar for that purpose in .Net Framework (for Windows Form).
But that's doesn't stop you from implementing it by yourself. Steps could be something like this:
1. Define the data structure, that will store the history of what your user visited (depends on what data you need to load the form/screen/whatewer to return back to given state).
2. Define the Control, that will move through your history.
I understood you.
so in the loop i set the size of sum as ( sumsize -1 ) because in adding we add from right to left and the first added number will located in the most significant location of the array
and then at the end of the loop i decrement the sumzie to move left to the next location of the array, and because that the sum array is bigger that the longer number by ( 1 ) location , there will be a place to the carry at the least significant location.
That's pretty clear, but also, from your words: you go through arrays and their length is 1 less than sum array has. So the first element of this array would never be changed. So, that's why I gave you a piece of code, that assigns that first element (if necessary).
About this:
about the last point ( 1.
for(int i=0;i<sumsize;i++)
)i cant see anything wrong in it
i did this because i want to display the elements of the sum array which is still wrong
after previous cycle (where you sum your numbers) the value of sumsize would be 1 (in any case). So you would should do something like this:
for (int i = 0; i < sum.Length; i++)
You're welcome .. please, mark this thread as Solved if your question is settled :)
Hm .. hard to say ..
The selection appears as soon as your treeView get the focus. You can also play around TabIntex Property. If it's set to 0 (so your treView will be the first selected control on your form) then the node in it will be selected.
The other way to go would be - changing TabIntex so that treeView get's the input focus not in the first place.
But if I were you - I would choose the event-handling way .. in my opinion it gives more tangible control over treeView (but that's probably the question of comfort for developer :) ) So - you decide.
Hello.
The troubles are starting here:
carry = 1;
You carry can be more than 1 .. so you should take the integer part of your holder:
carry = holder / 10;
Now, after summing all the numbers - you can still have something in your carry variable .. and shouldn't waste it:
if (carry != 0)
{
sum[0] = carry;
}
And one more mistake, or rather typo:
for(int i=0;i<sumsize;i++)
You just were increasing sumsize
in cycle... So it won't be the actual size of the sum.
Hello.
Interesting question ..
I couldn't find any property or method for this case, but here's some workaround. You can process the BeforeSelect event and cancel it if the selection made e.g. not using mouse:
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
if (e.Action != TreeViewAction.ByMouse)
{
e.Cancel = true;
}
}
Hello, Ryshad :)
Ok, let's go .. I'll give a few comments on your suggestions and then give you an example.
a) include a flag in the bay to show that it is in another step
No, you shouldn't. Because the Bay class shouldn't be aware of what's happening outside of it.
b) have the step check with the sequence to see if any steps contain it
Also sounds a bit weird .. if rephrase - it would be "the element of an collection should be aware of other elements in collection "
c) check in the main form and pass a colour to the draw method
That's seems the right abstraction level for that design. The Form contains the collection and can be aware of what stored in it. But, probably not passing a color, but calling the right method or calling method with parameters.
Ok, for the first sight that all may seem kinda confusing, but here's example:
Imho, the one of the best methods of explanation - is use of metaphors...
Let's imagine that class is a closed box. If you're inside that box - you can't see what is happening outside (see your a suggestion).
But if we outside the box - we can see some of it characteristics (the methods or data, that you opened for public viewing aka open interface of the class).
Now let's put a few boxes in a row .. we have now a collection …
Hello.
Let's investigate your code:
1. You declare an array (for some reason readonly). And say, that it would contain 1024 elements.
private readonly byte[] _buffer = new byte[1024];
NOTE: The array is still empty
2. On the next step you're trying to convert your empty (well, not really empty: just each element initialized by "0" and you haven't assigned any value in that array) array to Integer, starting from 0 position.
int structId = BitConverter.ToInt32(_buffer, 0);
Since you're trying to convert "Nothing to something" - it ain't gonna work. And that's, probably the reason of this:
here Im getting structId= 540029490 always.
The next trouble ..
aboue if condition also FALSE always.means its throwing ex.
Since I don't know what is Structs
and moreover the TryGetValue
method in it - I can't say exactly. But can take a guess .. that it returns false because of bad input (structId).
And that's the chain reaction .. the bad structId causes troubles with currentStructType. The corrupted currentStructType causes troubles in currentStruct and so on.
So to solve your problem you should start from structId.
P.S. If you'll place your code in code tags next time - it would be much easier to investigate it .. and you'll get the answers much faster :)
Well, the other way could be storing datatable/data in your main form. And pass them to other forms of your application at creation time.
Or if you really need to puch them into a single table:
maybe moove weeks in rows, like:
[B]Product Name | Weeks | Dept. 1 | Dept. 2| ...[/B]
-------------------------------------------------------------
Product 1 | Week1 | someth. | someth.| ...
------------------------------------------------
| Week2 | someth. | someth.| ...
------------------------------------------------
| Week3 | someth. | someth.| ...
-------------------------------------------------------------
Product 2 | Week1 | someth. | someth.| ...
------------------------------------------------
| Week3 | someth. | someth.| ...
------------------------------------------------
| Week7 | someth. | someth.| ...
-------------------------------------------------------------
Or maybe merge 2 cols/rows in 1, e.g.:
[B]Product Name | Dept. 1 | Dept. 2 | ...[/B]
-------------------------------------------------------------------------
Product 1 | Week1 (someth.),| Week1 (someth.),| ...
| Week2 (someth.),| Week2 (someth.),| ...
| Week3 (someth.) | Week3 (someth.) | ...
-------------------------------------------------------------------------
Product 2 | Week1 (someth.),| Week2 (someth.),| ...
| Week3 (someth.),| Week5 (someth.),| ...
| Week7 (someth.) | Week1 (someth.) | ...
-------------------------------------------------------------------------
Hello.
All you need is decide what objects to pass to that method and then - call it. E.g.:
comboBox1_SelectedIndexChanged(comboBox1, new EventArgs());
Hello, Ryshad.
I hope that I understood you corretcly :)
What if take your 3rd dimension out of gridview? (see pic 1).
If you have to display a few orders, that are split between different departments, and having different data about weeks and products - you can also take it outside gridview. E.g. creating something like on 2nd pic.
Hope, that this would help you :)
Hello.
In your case you can handle those keys in KeyDown event. It would be something like this:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
// if AltKey is pressed and the
//other Key is F4 then
if (e.Alt && (e.KeyCode == Keys.F4))
{
//we say, that we already handled that
//event by ourself and there's no need to pass
//this event to other handler, that will
//recognize the Alt+F4 and close the form
e.Handled = true;
}
}