|
if you don't check button state, if user moves his mouse with mousebutton clicked the program will still behave like the button would be clicked.
Pawel
|
|
|
|
|
I stand corrected, MouseUp OR MouseLeave.
I still think it's better to use available events then setting up timer and checking manualy. Then again, it's quite possible that I am missing something, since I've been doing exclusively web dev lately.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Malcolm Smart wrote: It's 0800hrs here, my brain doesn't get into gear until about 1000hrs, so there might be a much better way.
It's 1000 here, and I can't think of a much better way either.
Unless I take longer to get my brain into gear. In fact, I browse these forums every morning to do just that - start thinking in developer mode and not human mode anymore.
I do not believe they are right who say that the defects of famous men should be ignored. I think it is better that we should know them. Then, though we are conscious of having faults as glaring as theirs, we can believe that that is no hindrance to our achieving also something of their virtues. - W. Somerset Maugham
My New Blog
|
|
|
|
|
Might be the reason is not your code xml file is not formated correctly
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
princymg wrote: Previously i didnt check the xml file
Unbelievable.;)
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
:(sigh:Hi Everyone,
Okay in the past two weeks I have learnt so much and I'm starting to work things out on my own. However even this one is tricky for me.
I am trying to automatically check checkedlistboxes based on data in the database.
I know I have to compare the dataset tableadapter to items in the ckedlistbox and then tick them if they match the ID. But how? I have created a join table aswell with EmpID and TechSkillsID so that people can tick multiple skills and they will be saved in there. Even though it isn't working yet. and yes the foreign keys are set up correctly. My code doesn't tick anything.
This is my code.
[code]
sql = "Select t.ProgLanguagesDatabase,e.EmployeeID,e.TechnicalSkillsID from TechnicalSkills t, employees e where t.TechnicalSkillsID = e.TechnicalSkillsID and e.EmployeeID = '" + FirstnameText.Text.ToString() + "'";
for (int i = 0; i < techSkillsCheckListBox2.Items.Count; i++)
{
for (int j = 0; j < this.dataSet1.TechnicalSkills.Count;j++)
{
if (i == j)
{
techSkillsCheckListBox2.SetItemChecked(i, true);
}
}
Thank you so much
Sianny (aka Sharny)
|
|
|
|
|
falles01 wrote: if (i == j)
I think your logic is wrong. All you are doing is comparing two numbers - the index of the item in the collection. Imagine techSkillsCheckListBox2.Items has 4 items and this.dataSet1.TechnicalSkills has 5 items. Your loop will look like
<br />
0 = 0 : true<br />
0 = 1 : false<br />
0 = 2 : false<br />
0 = 3 : false<br />
0 = 4 : false<br />
<br />
1 = 0 : false<br />
1 = 1 : true<br />
1 = 2 : false<br />
1 = 3 : false<br />
1 = 4 : false<br />
<br />
<br />
2 = 0 : false<br />
2 = 1 : false<br />
2 = 2 : true<br />
2 = 3 : false<br />
2 = 4 : false<br />
<br />
and so on , which is not what you want. You need to iterate through the dateset, retrieve the identifier of the skill, which should match an identifier on the check box, and then set the check box.
Step through with a debugger and you will see what's happening.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Thanks. so I've heard. Just ignore i==j.I've tried everything and I know what the debugger is showing me but I would love to know exactly how to iterate through the dataset and compare the items in teh table to the items in my checkedlistbox. If the items are matching based on the techskillsID then I have to have them ticked. I have retrieved the ID by using
sql = "Select t.ProgLanguagesDatabase,e.EmployeeID,e.TechnicalSkillsID from TechnicalSkills t, employees e where t.TechnicalSkillsID = e.TechnicalSkillsID and e.EmployeeID = '" + FirstnameText.Text.ToString() + "'";
Can you suggest how I can create the if statement. I know we are supposed to be taught the logic and we find the answer ourselves, but I think I understand the logic but can't find the answer anywhere.Its the fact that I have a checkedlistbox, and a sql database and table adapters. its hard to find the exact answer when you have so many topics involved.
Thanks. Much appreciated.
|
|
|
|
|
I am assuming (hoping) that you create your CheckBoxList dynamically, and read the possible options from the db. When you do, you add the checks as ListItems. Something like
<br />
while (myreader.Read())<br />
{<br />
ListItem myCheckBoxItem = new ListItem( myreader["DESCRIPTION"].ToString() , myreader["ID"].ToString() );<br />
myCheckBoxList.Items.Add( myCheckBoxItem );<br />
}<br />
To select the relevant ones, read all the skills for a user from the database
<br />
sqlstring = "select skillID from userSkills where userID = 'myuser'";<br />
<br />
DataRow[] rows = dt.Select();<br />
foreach(DataRow row in rows)<br />
{<br />
string techID = row["skillID"].ToString();<br />
myCheckBoxList.Items.FindByValue( techID ).Selected = true;<br />
}<br />
And that's it. Please excuse typos etc as I can't get to a dev box to test this.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Thankyou. that was an excellent answer. I am trying it, how ever...will that work with a winform not a webform? In order to use Listitem I had to add the web reference system.web.ui.webcontrols and that causes 1137 errors.
Hmmmmmm Is there someway of reading the dataset with out listitems?
Thank you
Sianny. (Aka Sharny)
|
|
|
|
|
I am not reading the dataset with ListItems. I am reading the dataset with reader.Read() and then populating the checkboxlist with ListItems.
How did you create your checkboxlist? have you hardcoded all the entries in Visual Studio or do you create it dynamically?
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
I tried to copy your code but it won't let me use listitems at all because it belongs to webforms. I have used tableadapters and have used Technicalskills list to bind as below. Sorry I'm a little confused.
private void TechnicalSkillsList()<br />
{<br />
<br />
DataSet1TableAdapters.TechnicalSkillsTableAdapter technicalskillsTableAdapter = new ResourceSearchTool.DataSet1TableAdapters.TechnicalSkillsTableAdapter();<br />
<br />
DataSet1.TechnicalSkillsDataTable techSkillsDT = technicalskillsTableAdapter.GetData();<br />
<br />
foreach (DataSet1.TechnicalSkillsRow techSkillsRow in techSkillsDT.Rows)<br />
this.techSkillsCheckListBox2.Items.Add(techSkillsRow.ProgLanguagesDatabase);<br />
<br />
}<br />
|
|
|
|
|
I have worked out on my own how to save multiple skills. so now its down to automatically populating the checkedlistbox with the skills.
which still brings me back to my precious forum post,,,but I'm still working on it and i'm giving you a 5 for being such a good response anyway.
|
|
|
|
|
Okay I was wrong. I didn't work it out. I'm still trying to save multiple skills and I thought it was saving them but it was actually saving the number of the index instead of the ID. Here is what I'm using. I still need the answer of how to get the id of the ticked items and then store it.
<br />
string sql = "SELECT t.TechnicalSkillsID from TechnicalSkills where TechnicalSkillsID = '" + techSkillsCheckListBox2.CheckedItems.ToString() + "'";<br />
if (techSkillsCheckListBox2.CheckedItems.Count != 0)<br />
{<br />
<br />
<br />
<br />
for (int x = 0; x <= techSkillsCheckListBox2.CheckedItems.Count -1; x++)<br />
foreach (int i in techSkillsCheckListBox2.CheckedIndices)<br />
{<br />
<br />
sql = "Insert into EmpSkills(EmployeeID,TechnicalSkillsID) values ('" + this.EmployeeID + "','" + techSkillsCheckListBox2.CheckedIndices[x].ToString() + "')";<br />
<br />
SqlCommand adoCmd = new SqlCommand(sql, adoConn);<br />
adoCmd.ExecuteNonQuery();<br />
<br />
<br />
<br />
<br />
<br />
Thank you so much ...this is killing me! I thought I had it.
Sianny aka Sharny
|
|
|
|
|
how to connect xml file to form in windows applications and even to connect two forms in windows applications
Ramya
|
|
|
|
|
Don't crosspost in Multiple Forums.
SSK.
|
|
|
|
|
could you elaborate the question a bit more what u mean by connect xml to form in window application? As far as connecting 2 forms is concerned, u can create an object instance of form1 in form2 and call the show method to display the form, and if u want to send data across forms then better use overloaded constructors and pass data in constructors between forms.
Regards
|
|
|
|
|
You need to think about what you are trying to achieve with the connection of 2 forms. If they are just different views of the same underlying data, then you should really consider looking at either the Model View Controller or Model View Presenter patterns. There are plenty of samples on the web (especially here in CP) that show how to achieve this.
XML file? Do you mean to ask how to load it, or how to bind it to an item?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I have some blinking cursor in my RichText and in some other places in my WinForm.
How i remove it ?
Thanks.
|
|
|
|
|
If you are using Visual Studio there is a cursor property in the properties pane which gives you a list of options. If not there is a method you can try. If its not the deafult I'm sure the intellisense will give you a good option. Goodluck!
private void UpdateApplication_CursorChanged(object sender, EventArgs e)
{
Cursor.Current = Cursors.Default;
}
Sianny
|
|
|
|
|
Also could you let me know if I was correct?
Thanks
|
|
|
|
|
I looking a way to turn off / kill the line cursor that blink on rich text line in case you click on the line with the mouse.
You mean in your replay that the mouse cursor will change to the default shape - and this is not what i mean.
|
|
|
|
|
Hi All,
I'm new to C# and currently involve in a project that need me to interact with a device.They have provide me with the SDK that full with libraries written in c++. My question is can c# access a non .NET libraries?
Thanks,
-zai-
|
|
|
|
|
Yes, by using the System.Runtime.InteropServices namespace.
http://www.pinvoke.net/[^] is a very good site for information on running unmanaged code.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
Sure, there are basically two options for this. One is COM, this is only possible if the libraries are implemented as COM type libraries. Another option is DllImport, this is possible with normal C++ libraries.
You can import make a wrapper for a COM library using tlbimp.exe which is available with the .NET SDK.
You can import functions from a standard C++ library in the following manner:
public static class MyFunctionImports {
[DllImport("<dll name="">")]
public static extern void MyMethod(string text);
}
Of course you need to know the exact signature of the methods you need and the types that they need.
I know from experience that device libraries are almost always standard C++ libraries. So the second option fits best here.
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|