|
i am really pleased for your help and thanks for your assistance . moreover, i am new on C# and i will be more clear in my question in the future and that is right i need some reading. and i will not use turkish word in the future 
|
|
|
|
|
No worries, and you'll be doing yourself a big favour if you learn a bit about this.
Check OriginalGriff's posting below - that should really get you started in understanding what you need to do to make things work. Good luck!
|
|
|
|
|
Your problem is pretty obvious: Go back to the beginning, and look at what you are doing. I have cut your code down to just the relevant bits.
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
buton bt = new buton();
bt.kayit(@"C:\Users\Casper\Desktop\a.txt", textBox1.Text);
}
private void button3_Click(object sender, EventArgs e)
{
buton bt = new buton();
bt.silgi(@"C:\Users\Casper\Desktop\a.txt", Convert.ToInt16(textBox3.Text));
}
}
class buton
{
List<string> silici = new List<string>();
public void kayit(string path, string text)
{
silici.Add(text);
Console.WriteLine(silici.Count);
}
public void silgi(string path, int silineceksirasi)
{
Console.WriteLine(silici.Count);
silici.RemoveAt(silineceksirasi); ----> I GET MİSTAKE WHEN ı CLİCK BUTTON3!!!
}
}
If it is still not clear, try running these fragments through the debugger.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
i have solved problem thanks for your help friends and this is the best site i have ever seen and you are the greats 
|
|
|
|
|
can u tell what was the problem u were facing??
Thanks,
Amit Patel
|
|
|
|
|
Hi,
I am able to export dataset into excel using stringwriter and response method using c#.
but i want to save the excel file in a folder without opening the file.
could anyone help out please.
Thanks
|
|
|
|
|
|
Hey Programmr and amit thanks a lot for giving those url.it was very useful.
|
|
|
|
|
|
hi,
Use following link
Thanks and regards,
Amit Patel
|
|
|
|
|
I have a C# Silverlight 3 app composed of 2 calendar controls. Both have their own SelectedDateChanged event hooked up in the constructor of the class. When user changes the date in one of the controls, the SelectedDateChanged event is raised and some code is executed, mainly to update the SelectedDate property of the other control, but this will also raise the event in the other control as well. I don't want this to happen so, inside the code, before updating the SelectedDate property I disconnect the event in the other control, preventing it to be raised. The problem is that, at the end, when the event is reconnected, it fires, making this logic useless. Is there anyway to do the reconnection without firing the event?
public partial class Page1: UserControl
// Hook events in the Constructor
public Page1()
{
calendarCheckInDate.SelectedDateChanged +=new EventHandler<SelectionChangedEventArgs>calendarCheckInDate_SelectedDateChanged) ;
calendarCheckOutDate.SelectedDateChanged +=new EventHandler<SelectionChangedEventArgs>(calendarCheckOutDate_SelectedDateChanged);
}
// Call event in normal operation
private void calCheckInDate_SelectedDateChanged(object sender,SelectionChangedEventArgs e)
{
// disconnect event on other control
calendarCheckOutDate.SelectedDateChanged -= calendarCheckOutDate_SelectedDateChanged;
try
{
// run some business logic code
.....
.....
calCheckOutDate.SelectedDate.Value = someothervalue;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
// Reconnect the event in the other control.
// NOTE: THE EVENT WILL BE RAISED HERE
calendarCheckOutDate.SelectedDateChanged += calendarCheckOutDate_SelectedDateChanged;
}
}
}
|
|
|
|
|
I can't say why the event is being raised; from what you have shown it shouldn't be raised. However, an alternate way to handle the problem would be to not remove the handlers at all. Instead you could use a guard flag to determine if you are changing the value from inside the other handler.
private bool inHandler;
private void calCheckInDate_SelectedDateChanged(...)
{
if (inHandler) return;
try
{
inHandler = true;
}
finally
{
inHandler = false;
}
}
|
|
|
|
|
I've applied your sugestion and it works. However, since the "finally" clause executes before the event in the other control is raised, I moved the "inHandler = false" inside the other control.
I really would have preferred to disconect the event but your idea does the work as well.
Thanks!
Cid
|
|
|
|
|
Hi
I have constructed two straightforward named pipes, but problem is how to start them off together in their own threads in order to commence the transfer of messages.
Do some research, I have noticed that some of my solution may be found in delegates using begin invoke, invoke and end invoke. Unfortunately, I need some help as I am little new to this.
So, could someone please advise me how it would be possible to give a named pipe client stream and a named pipe server stream their own thread and to start them off together in their own thread with using delegates?
Thanks
|
|
|
|
|
Just a suggestion....
make each end a wcf endpoint
set the attributes to use NamedPipes
pass the data over the wcf pipline
|
|
|
|
|
Hi everyone, i wanted to know if someone here knows where could i find some tutorials to accomplish the following:
I want to make a silverlight app that shows in a main screen a pictures of a room, let´s say a living room, and i want to have a small menu at the left with a scroll bar with different things in it(different lamps, flowers, candels, etc.) and what i want to do is to drag and drop the desired element and place it into the main picture (living room).
Im pretty much a newbie so any tutorial that you can point at will be really usefull.
Thanks in advanced.
modified 6-Apr-22 21:01pm.
|
|
|
|
|
Whilst you may get an answer from somebody here, you would be better to post this in the Silverlight Forum.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
First, let me say that I am not a C# programmer. Complete newb here... Don't hate me because I'm beautiful...
I am trying to create a drop-dead simple application that will set a function callback address in the C++ COM dll to point to a C# function in the demo application. (This is for a sample application to demonstrate our API to potential users.) I have it working for both C++ and Visual Basic, but thus far, C# success is eluding me.
Here is what I have done...
Created a simple form with three text boxes that will be filled with XYZ values when everything works.
Within the namespace of my app (TestCSharpApp... so I lack imagination... sue me...) I have created a delegate function like this.
public delegate void coordCallbackFunction(double x, double y, double z, int buttonNumber );
In my public partial class Form1 : Form class, I have the function I want to call.
public void coordHandler(double x, double y, double z, int buttonNumber)
{
xCoord.Text = x.ToString();
yCoord.Text = y.ToString();
zCoord.Text = z.ToString();
}
Finally, In the form load function I have this code.
MyCOMInterfaceLib.MyCOMClassClass myApi = new MyCOMInterfaceLib.MyCOMClassClass();
myApi.coordCallback += new coordCallbackFunction(this.coordHandler);
I realize that myApi will go away right after setting up the callback, but I am just trying to get it to compile. I'll worry about details later.
When I compile the program I get this error...
Error 1 Cannot implicitly convert type 'TestCSharpApp.coordCallbackFunction' to 'MyCOMInterfaceLib._IMyCOMClassEvents_coordCallbackEventHandler' C:\Temp\TestCSharpApp\Form1.cs 38
I have included the MyComInterfaceLib in my list of references. I can call functions from the COM dll and that works fine. The problem is setting the callback function using delegates.
It may not mean much, but the callback functions work fine in VB.Net, so I don't think the problem is in the COM dll.
Thank you for any help.
|
|
|
|
|
I really don't like answering my own questions...
Apparently C#, unlike VB, automatically creates delegates for COM events. So instead of creating my own function I use theirs.
Code then becomes,
myApi = new MyCOMInterfaceLib.MyCOMClassClass();
myApi.coordCallback += new _IMyCOMClassEvents_coordCallbackEventHandler(this.coordHandler);
If there is a better or easier way to do this, please let me know.
Otherwise, thank you.
- Matt
|
|
|
|
|
I have a DataGridView. I am in need of adding additional properties to each row. I would assume this would consist of extending the DataGridViewRow class.
If my assumption is correct, how would I implement this class so that when adding rows to the datagridview, each row is created as a ExtendedDataGridViewRow rather than a DataGridViewRow.
If I am completely heading in the wrong direction, what would be a better way of accomplishing my goal?
Thanks in advance!
|
|
|
|
|
theallmightycpd wrote: I have a DataGridView. I am in need of adding additional properties to each row.
You seem to have already decided how to proceed.
theallmightycpd wrote: If I am completely heading in the wrong direction, what would be a better way of accomplishing my goal?
Or maybe not.
Seriously, it will be very difficult for anyone to advise you accurately because you have not described what it is you are trying to do. Forget about the 'extending DataGridViewRow' stuff and describe the problem that made you decide that that is the way to go in the first place.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
First of all, I want to add a filter to the datagridview. I have completed this step by adding dropdowns to the column headers that populate with that columns values (uniquely). When a row does not match the current filter, its visibility is set to false.
Next, I want to add the ability to expand and collapse similar rows. For instance, if Row A contains the values {Test,1,2,3} and row B contains that values {Test,A,B,C}, the row can be collapsed into a header row with just the value {+,Test}. The plus symbol would be used to expand back into the two rows. A - on the header row will collapse back in to just the single row. When rows are collapsed, I am setting their visibility to false, also.
Currently, these features work separately, but do not work together. When a row's visibility is false, I don't know if it's because it doesn't match the filter or if the row is collapsed. What I would like to do is to add additional properties to each row describing when it is a row included or excluded in the current filter and another property for the expand/collapse header rows describing how many rows are assosicated with that header.
I hope this makes my intentions clearer.
|
|
|
|
|
What you are trying to do sounds a little like a cross between a TreeGridview[^] and OutlookGrid: grouping and arranging items in Outlook style[^].
I hope that the links above will at least give you some ideas, if you haven't seen them before.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm working on my first C# project, first real programming in a while. Not exactly like riding a bike...
I'm trying to create a class or struct that contains a StringBuilder. Truthfully, either class or struct, either string or StringBuilder should work OK, but a class with StringBuilder seems like the *right* solution. But I get errors.
Here is the class:
public class sheetCols
{
string colHdg;
public string colLetter;
public StringBuilder colValue = new StringBuilder(" ");
public sheetCols(string s1, string s2, string s3)
{
this.colHdg = s1;
this.colLetter = s2;
this.colValue.Length = 0;
this.colValue.Append(s3);
}
}
The error I see on the constructor is:
Field 'RAContractToolConsole.Program.sheetCols.colValue' must be fully assigned before control is returned to the caller
The warning on the Length assignment is:
Use of possibly unassigned field 'colValue'. Struct instance variables are initially unassigned if struct is unassigned.
I looked around on CodeProject and elsewhere online; can't find an answer. One post alluded to a bug in VS, but that was v7, and I'm on VS2008 (aka v9), updated according to Windows Update.
What am I missing? Is it possible to use a StringBuilder inside another class? I couldn't find an example online.
Thanks in advance.
|
|
|
|
|
Hi,
when sheetCols is a class (as in your snippet), the code is fine.
when sheetCols is a struct, it would not be OK:
- you can't have initializers on struct members;
- every consrtuctor needs to initialize all data members.
Here are some suggestions for you:
- tell your IDE to always show line numbers in editor windows (see here[^]);
- watch the squiggly lines (red or green) Visual Studio uses to flag problems;
- watch the errors and warnings any IDE will produce; and focus on the first one first; you must get rid of all errors before you can execute, and it is wise to also get rid of the warnings.
- be meticulous; every single keyword and punctuation mark matters.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|