|
public bool FindMyText(string text)
{
// Initialize the return value to false by default.
bool returnValue = false;
// Ensure a search string has been specified.
if (text.Length > 0)
{
// Obtain the location of the search string in richTextBox1.
int indexToText = richTextBox1.Find(text);
// Determine whether the text was found in richTextBox1.
if(indexToText >= 0)
{
returnValue = true;
}
}
return returnValue;
}
mahes
|
|
|
|
|
|
I have a combobox and is populated from a datatable. The problem is that I have in my table rows with the same value for that column so I want that in combobox to appear that values only once because when I select a value from the combobox my datagrid to display only the lines with that value in the specified column. The combobox stores the months and in my datagrid I want to display the items from that specified month. I will show my code below:
public FModificareDate()
{
InitializeComponent();
conAccess.Open();
daMembrii.Fill(odsDate, "tb_membrii");
daUnitate.Fill(odsDate,"tb_unitate");
DataTable dataTableMembrii = odsDate.Tables["tb_membrii"];
#region Definire coloane datagrid Membrii
//Setarea numelor coloanelor din datagrid
// create a DataGridTableStyle object and initialize
// based on the dataTable's TableName.
DataGridTableStyle tableStyleMembri = new DataGridTableStyle( );
tableStyleMembri.MappingName = dataTableMembrii.TableName;
// Get the GridColumnsStylesCollection
// from the table style's GridColumnStyles collection
GridColumnStylesCollection columnStylesMembri = tableStyleMembri.GridColumnStyles;
// Make a columnStyle object and add column info to it
// then add the columnStyle to the columnStyles collection
DataGridColumnStyle columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_codcmr";
columnStyleMembri.HeaderText = "Cod CMR";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_codparafa";
columnStyleMembri.HeaderText = "Cod Parafa";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_cnp";
columnStyleMembri.HeaderText = "CNP";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_nume";
columnStyleMembri.HeaderText = "Nume";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_prenume";
columnStyleMembri.HeaderText = "Prenume";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_luna";
columnStyleMembri.HeaderText = "Luna";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_an";
columnStyleMembri.HeaderText = "Anul";
columnStylesMembri.Add(columnStyleMembri);
columnStyleMembri = new DataGridTextBoxColumn( );
columnStyleMembri.MappingName = "pers_suma";
columnStyleMembri.HeaderText = "Suma Totala";
columnStylesMembri.Add(columnStyleMembri);
GridTableStylesCollection tableStylesMembri = dgMembri.TableStyles;
tableStylesMembri.Add(tableStyleMembri);
#endregion
dgMembri.DataSource = dataTableMembrii;
DataTable dataTableUnitate = odsDate.Tables["tb_unitate"];
#region Definire coloane datagrid Unitate
// create a DataGridTableStyle object and initialize
// based on the dataTable's TableName.
DataGridTableStyle tableStyleUnitate = new DataGridTableStyle( );
tableStyleUnitate.MappingName = dataTableUnitate.TableName;
// Get the GridColumnsStylesCollection
// from the table style's GridColumnStyles collection
GridColumnStylesCollection columnStylesUnitate = tableStyleUnitate.GridColumnStyles;
// Make a columnStyle object and add column info to it
// then add the columnStyle to the columnStyles collection
DataGridColumnStyle columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "unit_id";
columnStyleUnitate.HeaderText = "ID";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "unit_tip";
columnStyleUnitate.HeaderText = "Tip";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "unit_denumire";
columnStyleUnitate.HeaderText = "Nume Unitate";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_tara";
columnStyleUnitate.HeaderText = "Tara";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_secjud";
columnStyleUnitate.HeaderText = "Sector/Judet";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_localitate";
columnStyleUnitate.HeaderText = "Localitate";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_tip";
columnStyleUnitate.HeaderText = "Tip Adresa";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_denumire";
columnStyleUnitate.HeaderText = "Denumire";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_codpostal";
columnStyleUnitate.HeaderText = "Cod Postal";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_nr";
columnStyleUnitate.HeaderText = "Nr";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_bloc";
columnStyleUnitate.HeaderText = "Bloc";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_scara";
columnStyleUnitate.HeaderText = "Scara";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_etaj";
columnStyleUnitate.HeaderText = "Etaj";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_apartament";
columnStyleUnitate.HeaderText = "Apartament";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_compladresa";
columnStyleUnitate.HeaderText = "Completari Adresa";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_fix1";
columnStyleUnitate.HeaderText = "Telefon Fix1";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_fix2";
columnStyleUnitate.HeaderText = "Telefon Fix2";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "adr_fax";
columnStyleUnitate.HeaderText = "Fax";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "persc_nume";
columnStyleUnitate.HeaderText = "Nume Persoana Contact";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "persc_prenume";
columnStyleUnitate.HeaderText = "Prenume Persoana Contact";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "persc_tel";
columnStyleUnitate.HeaderText = "Telefon Persoana Contact";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "ind_nr";
columnStyleUnitate.HeaderText = "Indicator control";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "ind_tot";
columnStyleUnitate.HeaderText = "Total";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "ind_luna";
columnStyleUnitate.HeaderText = "Luna";
columnStylesUnitate.Add(columnStyleUnitate);
columnStyleUnitate = new DataGridTextBoxColumn( );
columnStyleUnitate.MappingName = "ind_an";
columnStyleUnitate.HeaderText = "Anul";
columnStylesUnitate.Add(columnStyleUnitate);
GridTableStylesCollection tableStylesUnitate = dgUnitate.TableStyles;
tableStylesUnitate.Add(tableStyleUnitate);
#endregion
dgUnitate.DataSource = dataTableUnitate;
txtMembri.Text = dataTableMembrii.Rows.Count.ToString();
dSumaCotizatii = 0;
for(int i=0; i
|
|
|
|
|
Hi,
I am working on the treenodes in C# and am facing a prob. I want to dynamically populate treenode with a filename immediately after saving a file in a particular folder. Can I do this without writting any seperate function.
Or is there any other way?.
Looking forward for some help.
Thanks and Regards
KR
|
|
|
|
|
Hi All,
I was not able to display complex classes in the propertygrid and hence had to use UITypeEditors for doing that.
I am actually trying to display the properties of a class object inside the property grid which has another class object as one of its property .(can go deep)
The problem is that the object which is the property is getting grayed out even though i am using UITypeEditor (Comboboxlisteditor) to do so.
So no point in thinking of more deeper object properties.
I have tried all places to search for such a code which has a propertygrid displaying complex classes and enums . I could not find one .
So please spare some time and pass on some simple code which can display complex class objects and enums inside the propertygrid .I just need the minimum . I have referred to MSDN and few other articles from codeproject which was helpful to a certain extent but not for this problem .
I have spent more than 3-4 days in researching the things on this .
Please help me in getting it done .
Thanks and Regards,
DJ
|
|
|
|
|
|
Thanks for that Leppie.
But i dont want to use typeconverters, rather i would like to use custom type editors to solve my problem . wish i can get some piece of sample code which is tested having the required attributes.Because the attribute is not being able to pick up properly which is as follows
[Editor("WindowsFormsPropertyBag1.Form1.ComboBoxListEditor",typeof(System.Drawing.Design.UITypeEditor))]. Do you need more information about the problem??.
Thanks and Regards,
IianforCodeProject
|
|
|
|
|
Good Day People,
I have a DLL. It takes in some parameters, and returns some output. This DLL has to be called form a EXE, which has a GUI Interface.
The portion of code where the DLL returns the solutin is pasted below.
The doubt is; when I call the DLL it returns "n" solutions. I need to take the first solution and show output, while the DLL should be proessing the other solutions.
So I think I should be raising an event, that outputs the first solution. I dot know how to handshake between my EXE and DLL properly. Can you assist?
------------------------------------------------
Code:
------------------------------------------------
forward = true;
while (!myStack.IsEmpty())
{
if (forward)
{
CurrentPtr = -1;
}
else
{
CurrentPtr = (int) myStack.Pop();
CurrentSolution.RemoveAt(myStack.Count);
myArray.RemoveAt(CurrentSolution);
}
CurrentWord = this.Problem.NthWord(myStack.Count);
strExistingWord = myArray.GetStringAt(CurrentWord);
myDict = (Dict) Dicts[myStack.Count];
newPtr = myDict.GetWord(strExistingWord,CurrentPtr, ref strNewWord);
if (newPtr != -1 )
{
CurrentWord.Word= strNewWord;
CurrentSolution.AddWord(CurrentWord);
myStack.Push(newPtr);
myArray.StoreAt(CurrentWord);
forward = true;
if(myStack.Count == this.ProblemSize)
{
Solution newSolution = CurrentSolution.Clone();
this.alSolutions.Add(newSolution);
//return;
// newSolution.writeSolution();
// System.Console.ReadLine();
forward = false;
}
}
else
{
forward = false;
// show the combinations
//this.show(myStack.ToArray());
//System.Console.Write("{0} ", ShowInPC(myStack.ToArray(),Dicts));
}
}
return;
Md. Sathik
|
|
|
|
|
Good Day People,
I have a DLL. It takes in some parameters, and returns some output. This DLL has to be called form a EXE, which has a GUI Interface.
The portion of code where the DLL returns the solutin is pasted below.
The doubt is; when I call the DLL it returns "n" solutions. I need to take the first solution and show output, while the DLL should be proessing the other solutions.
So I think I should be raising an event, that outputs the first solution. I dot know how to handshake between my EXE and DLL properly. Can you assist?
------------------------------------------------
Code:
------------------------------------------------
forward = true;
while (!myStack.IsEmpty())
{
if (forward)
{
CurrentPtr = -1;
}
else
{
CurrentPtr = (int) myStack.Pop();
CurrentSolution.RemoveAt(myStack.Count);
myArray.RemoveAt(CurrentSolution);
}
CurrentWord = this.Problem.NthWord(myStack.Count);
strExistingWord = myArray.GetStringAt(CurrentWord);
myDict = (Dict) Dicts[myStack.Count];
newPtr = myDict.GetWord(strExistingWord,CurrentPtr, ref strNewWord);
if (newPtr != -1 )
{
CurrentWord.Word= strNewWord;
CurrentSolution.AddWord(CurrentWord);
myStack.Push(newPtr);
myArray.StoreAt(CurrentWord);
forward = true;
if(myStack.Count == this.ProblemSize)
{
Solution newSolution = CurrentSolution.Clone();
this.alSolutions.Add(newSolution);
//return;
// newSolution.writeSolution();
// System.Console.ReadLine();
forward = false;
}
}
else
{
forward = false;
// show the combinations
//this.show(myStack.ToArray());
//System.Console.Write("{0} ", ShowInPC(myStack.ToArray(),Dicts));
}
}
return;
|
|
|
|
|
HI
I'm beginner in C# Builder, And need to know how I can read from textbox or richtextbox.
And how I should draw Function like (y=sin(x)), IN VB usually drawing is in picturebox,
but I'm not very familiar with C# structure. I need the source code, cause I Havn't enough
time now to learn it, I should learn it later. if you can guide me.
thank you.
TA RedStar
|
|
|
|
|
|
Hello again! I'm on the last stretch of my 1st ever c# program and I really need help in solving this last, yet possibly hardest problem i've encountered yet.
Well I have this program that saves the output of my query in a datagrid into text file. I've accomplished half of it meaning I can save it at a target location but:
1. Why can I only save it in specific folders like c:\Temp? I'm hoping I could save it on the desktop.
2. Why doesn't a command prompt appear when I click the save button? It save directly and doesn't even inform the user that it has been saved although it already is.
3. How do I solve this problem?
I've tried searching the net for possible solutions but failed. Here's my code:
private void btnSave_Click(object sender, System.EventArgs e)
dtMain = objBM.fMain(DropDownList1.SelectedItem.Value,DropDownList2.SelectedItem.Text);
StreamWriter sr = File.CreateText("c://Temp//SSS.txt");
string strout;
if (dtMain.Rows.Count > 0)
{
for (int intptr = 0; intptr <= dtMain.Rows.Count - 1; intptr++)
{
strout = " ";
for (int intptr2 = 0; intptr2 <= dtMain.Columns.Count - 1; intptr2++)
{
strout += dtMain.Rows[intptr].ItemArray[intptr2] + " ";
}
sr.WriteLine(strout);
}
}
sr.Close();
}
Any and all suggestions, reactions and informations would be greatly appreciated. Thanx for all your helps!
thanx
|
|
|
|
|
1) you can save it anywhere you choose to - try searching for Environment.SpecialFolders.Desktop to find out more about getting the desktop directory. At the moment you are creating a file in the specific path with this line - StreamWriter sr = File.CreateText("c://Temp//SSS.txt");
2)If you want a dialog to appear try looking into the saveFileDialog control (it should be on the toolBox by default)
Then you could use the FileOk event of this control to save the file to wherever the user has selected.
|
|
|
|
|
Are there some compiler or .NET framework predefined macros, such as the _ATL_VER, _MFC_VER, _MSC_VER for the C#?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Macros suck, I regret that C# supports them at all. Yes, I believe there is DEBUG for debug versions, and TRACE also. They are shown in the project properties for a debug build, you can add more.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks.
I do not see what is regretable about macro support in C#. You simply do not have to use what you do not have a use for. I needed to create an interface library for both .NET 1.1 and 2.x, and do not want to do this again. So, I want to have something like
#if version 1.x
IPositionList Positions
#else // version 2.x
List<IPosition> Positions
#endif
{
get;
}
where is a IPositionList is a strongly-typed list of IPosition for use in
the version 1.x.
I do not know if anything else can do this better than macros. I will defined my own macros - just trying to find out if "standard macros" exist
for this kind of stuff.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
I do not see what is regretable about macro support in C#.
I agree, I have been thinking of using the C/C++ preprocesser on C# but havent got that far :p As CG said, DEBUG TRACE are common defines, but they are ONLY used inside the project your are compiling and has no effect on dependant assemblies, like u would have in C/C++.
So your best bet is to use something like VERSION_1 and VERSION_2. Remember you can use this to your advantage as follows (the compiler might have some issues IIRC):
#define VERSION_1
using AnyPositionList =
#if VERSION_1
IPositionList
#else
List<IPosition>
#endif
;
Now in your code:
AnyPositionList Positions
{
get ..... ;
}
HTH
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
Thanks for the information.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
I do not see what is regretable about macro support in C#.
I agree with Stroustrup on macros. I think they suck. Having said that, I can't imagine any way of supporting a debug build without them, so I'm sure I'll use them at some point.
Paul Selormey wrote:
I do not know if anything else can do this better than macros.
Sure. The version 1.x code will just work in both cases though.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all...
Can there be an optional or default parameter in C#? If yes what would be the syntax of the same?
|
|
|
|
|
You can define a params collection, otherwise you need to write several methods like this":
void DoSomething(int i, int j, in k)
{
}
void DoSomething(int i, int j)
{
DoSomething(i, j, 5);
}
void DoSomething(int i)
{
DoSomething(i, 2, 5);
}
Obviously, this is less than ideal.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ya...one option is of method overloading, but when we have more number of params to be kept as optional one has to type a lot. Is there any other work around as in VB.NET we have an optional keyword which specifies the parameter is optional and with the specified default value.
|
|
|
|
|
To reiterate: no.
I recently found out that VB.NET supports optional parameters and C# does not. Until then, I thought that VB.NET was always the loser, I guess that's not the case.
Having said that, I think that an interface where a method takes 20 parameters and 10 are optional is just sloppy coding anyhow.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
C# vs VB is all a matter of style.
If you look closely at the features of both languages, you'll see that VB offers about as many features that C# doesn't have that C# offers that VB doesn't have.
C#:
- allows unsafe code (I've yet to meet anyone who does this in C# though)
- has the 'as' operator (but VB has it in 2005 - 'TryCast')
- allows assignments within expressions (e.g., if ((x = y.Value) == 2))
- operator overloading
VB:
- has optional parameters
- allows types within interfaces (although I've never wished I had this in C#)
- has a very flexible Select construct (much, much more flexible than 'switch')
- has the "When" filter for catch block headers (ok - I'm really stretching now...)
And this one is a doubtful benefit of VB: it gives you half a dozen ways to do a lot of things - some regard it as a benefit, while others hate it since it makes it harder to produce standard code in teams.
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
|
|
|
|