|
I am use FillCombo to Form Load Event to FillCombo Box
Sir Hear Some Mistact Of my Coding But Hear I Dont't Find That.
If Sir U Have Any Other Idea to FillCombo so Plese Tell Me Please
|
|
|
|
|
aajignesh wrote: If Sir U Have Any Other Idea to FillCombo so Plese Tell Me Please
As I said, it depends where the data is coming from. Is it coming from SQL Server 2005 database? If it is one possibility could be to use recursive CTE (Common Table Expression).
However, I made a little sample on your data. Since I don't have your datasource I had to make it differently so the implementation is a bit different. Try this. As far as can see, it fills a combo named cmbTest as expected. If the result is what you want, modify it in little pieces to implement it the way that's suitable for you:
Start in form load
private void Form2_Load(object sender, EventArgs e) {
FillCombo();
}
Method to always get the same data
private DataTable GetDataTable() {
DataTable data = new DataTable();
data.Columns.Add("Id", typeof(int));
data.Columns.Add("ParentId", typeof(int));
data.Columns.Add("LevelName", typeof(string));
data.Rows.Add(2, null, "Account");
data.Rows.Add(3, 2, "Perment");
data.Rows.Add(4, 2, "Tempray");
data.Rows.Add(11, null, "Sales");
data.Rows.Add(12, 11, "tttttt");
data.Rows.Add(13, 11, "pppp");
data.Rows.Add(14, 12, "qqqqq");
data.Rows.Add(15, 13, "jjjjj");
data.Rows.Add(16, 15, "asd");
data.Rows.Add(17, 16, "sasda");
data.Rows.Add(20, 17, "fffff");
data.Rows.Add(23, null, "Purchase");
data.Rows.Add(28, 23, "Pur1");
data.Rows.Add(30, 20, "qqqqqqq");
data.Rows.Add(31, 14, "aaaa");
data.Rows.Add(32, 15, "bbbbbbbb");
data.Rows.Add(33, 32, "iiiiiii");
data.Rows.Add(34, 3, "Company Employees");
data.Rows.Add(35, 4, "Contract Base Employee");
return data;
}
Main point for recursion
public void FillCombo() {
DataTable dt = GetDataTable().Clone();
DataRow startRow = GetDataTable().Select("LevelName = 'Sales'")[0];
AddChildren((int)startRow["Id"], ref dt);
this.cmbTest.DisplayMember = "LevelName";
this.cmbTest.ValueMember = "Id";
this.cmbTest.DataSource = dt;
}
And the recursion
private void AddChildren(int parentId, ref DataTable TableToFill) {
DataRow[] children = GetDataTable().Select("ParentId = " + parentId.ToString());
for ( int i = 0; i <= children.Length- 1; i++) {
TableToFill.ImportRow(children[i]);
AddChildren((int)children[i]["Id"], ref TableToFill);
}
}
|
|
|
|
|
|
|
I have created a .dll and it has a .config file. The application which will call this .dll also will have a .config file. If within my .dll I have code such as:
string con = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
Does the .dll look in its own .config first and then looks in the app's .config or does it decide some other way?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
It looks the applications config file.
|
|
|
|
|
So how can we differentiate so the .dll can look at its own .config as well as the application .config file?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
|
I'm setting up a search and I want the user to be able to decide if they want to see results based on a particular state of a boolean column in the table or ignore it and retrieve all rows regardless of the boolean state. (I hope that makes sense)
Essentially I want the user to be able to set a checkbox as checked, unchecked, or indeterminate and have my program act on any three of these states. Is it possible to catch an indeterminate checkstate? If so, how? As far as I can tell, both checked and indeterminate return a true checked value, so I can't use null, and there is no checkstate value for indeterminate.
Help! (Thanks in advance! Any help or advice would be tremendously appreciated!)
|
|
|
|
|
Check the CheckState property (no pun intended!).
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Can you elaborate? It sounds as though you're telling me to do what I've already tried. I need a different action for all three checkstates: checked, unchecked and indeterminate.
|
|
|
|
|
Set the CheckBoxes ThreeState property to true, then use a switch to determine the search scope.
switch (checkBox1.CheckState)
{
case CheckState.Checked:
break;
case CheckState.Indeterminate:
break;
default:
break;
} If you want the action to take place when the CheckBox is clicked, use the CheckStateChanged event, not the CheckedChanged as the latter doesn't respond to Indeterminate.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hm... That's interesting. Does this only work in a switch statement? I was trying to use an if statement with no success.
Thank you for your help, Davey.
|
|
|
|
|
If statements will work fine
if (checkBox1.CheckState == CheckState.Checked)
{
}
else if (checkBox1.CheckState == CheckState.Indeterminate)
{
}
else
{
}
Lodeclaw wrote: Thank you for your help
No problem
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
i have problem in this control
please help me
when i put the my control in form give me error message
but not define error
public partial class rado : UserControl
{
protected internal List<RadioButton> rd = new List<RadioButton>();
public List<RadioButton> Rd
{
get
{
return rd;
}
set
{
rd=value;
dro();
}
}
public RadioButton this[int index]
{
get
{
return rd[index];
}
set
{
rd[index] = value;
}
}
public rado()
{
InitializeComponent();
}
private void dro()
{
this.Controls.Clear();
for (int i = 0; i < rd.Count; i++)
{
this.Controls.Add(rd[i]);
}
}
}
modified on Friday, January 23, 2009 5:03 PM
|
|
|
|
|
Three times is way too many - please stop hitting submit NOW!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
khaled_0b wrote: i have problem in this control
please help me
So, what is the problem? Termites? Bad hair day? Freeze burn?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
when i put the my control in form give me error message
but not define error
|
|
|
|
|
I'm not quite sure what you're hoping to achieve - but the error is fixed by marking the Rd property as non serializeable in the designer by putting this attribute before it.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
i went create RadioButtonListBox control like checkedListBox
with additional PROPERTIES
where i set
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
modified on Friday, January 23, 2009 5:39 PM
|
|
|
|
|
You're a long way off track. You'll be struggling to make it work doing it the way you are.
Examine the CheckedListBox source to see how Microsoft do it, then adapt that to your own needs. There's alot to learn to create such an advanced control - beyond the scope of a forum such as this until you get into more specific details IMO.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hello all,
I'm working on a program using MS SAPI 5 where people can have a verbal conversation with a virtual person. I know the general content of these conversations, so I could limit the dictation grammar, and hopefully get much better speech recognition. I just can't quite figure out how to limit the dictionary. Does anyone here know how to define a limited domain grammar in SAPI 5?
I'm using C#, here's the instantiation of my dictation grammar and recognizer:
System.Speech.Recognition.SpeechRecognizer _recognizer = new SpeechRecognizer();
DictationGrammar dictGrammarContext = new DictationGrammar("grammar:dictation");
dictGrammarContext.Name = "Contextual Dictation Grammar";
dictGrammarContext.Enabled = true;
_recognizer.LoadGrammar(dictGrammarContext);
_recognizer.SpeechRecognized += new EventHandler<speechrecognizedeventargs>(DictReco_Event);
_recognizer.SpeechHypothesized += new EventHandler<speechhypothesizedeventargs>(DictHypo_Event);
</speechhypothesizedeventargs></speechrecognizedeventargs>
Any kick in the right direction (even towards a more appropriate forum) would be appreciated.
|
|
|
|
|
Hi Guys, working on an app at the mo that has a db,
the thing is, is that at the moment the db is hard coded to point to c:\mydatabase.
but obviosuly what i want to do is deploy the app to the local os drive,
but how do i do this in code, and need to make sure in the code knows where to find the db.
|
|
|
|
|
Relative directorys, put your DB in your application folder and then use System.Windows.Forms.Application.ExecutablePath and it will point to the db.
|
|
|
|
|