|
Hi I'm posting a new question in case Malcolm doesn't read my reply in time.
Basically what is wrong with this code? I want to automatically check the checklistbox items depending on if the items match the employees TechnicalSkillsID in the database table. Malcolm gave me a web form example which was a great response except I forgot to tell him I was using a winform.
can you help at all?
int i;<br />
<br />
for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++)<br />
{<br />
while (adoDR.Read())<br />
{<br />
sql = "Select em.TechnicalSkillsID,t.ProgLanguagesDatabase from EmpSkills em,TechnicalSkills t where EmployeeID = '" + FirstnameText.Text + "' and em.TechnicalSkillsID = t.TechnicalSkillsID";<br />
<br />
DataRow[] rows = dataSet1.TechnicalSkills.Select();<br />
foreach (DataRow row in rows)<br />
{<br />
string techID = row["TechnicalSkillsID"].ToString();<br />
techSkillsCheckListBox2.SetItemChecked(i, true);<br />
}<br />
}<br />
}
Sianny aka Sharny
|
|
|
|
|
falles01 wrote: for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++)
Why not
i < techSkillsCheckListBox2.Items.Count ?
Or even
foreach (CheckBox box in techSkillsCheckListBox2.Items) ?
This code is really broken. What you want to do, is fill a list with the items that are selected, then go through each check box and do something like
checkbox.Checked = (myListOfItems.Contains(theKEyForThisCheckbox));
Of course, I just invented some variables, assume the Tag of the checkbox contains the key value, so you can look it up. The code you're presenting does a nested loop, and just sets each box to be checked, over and over again.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks but the part you are talking about that is wrong, is actually the part that is correct and gives the correct value. I got that off msdn. Yes I want to fill a list with items but as i said, I can't use listitems as I'm using a winform so I would like to know how I do that exactly. How do you check the items against the ID's against an empID in the database?
Sianny aka Sharny
|
|
|
|
|
If you have a list of items and want to fill the control with them, you should be able to set the control's DataSource property with the list, and it should work.
That code is from MSDN ? It's REALLY messy, especially with the nested loop. Do you have a link ? I believe you, I'm just interested.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm not sure what you mean but i think I have filled the list already as you said as the items are there. I just need the ticked items to save as correct ID's in the database against a given employee. I would've used bits and pieces of msdn stuff so that might be why its messy. I didn't copy a whole paragraph of code, just a line here and there.
<br />
public override 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 />
}
|
|
|
|
|
and how do you fill a list with the checked items by the way?
|
|
|
|
|
and what sort of list? I have a checkedlist box which is filled with data from the dataset.
|
|
|
|
|
Hey,
I am trying to draw a line on a bitmap. I have tried using System.Drawing.Graphics, however this apparently only works with forms. When I try the following code:
System.Drawing.Graphics.DrawLine(drawerpen, lastpoint, currentpoint);
I get an error saying that I must create an object instance to use this. However, System.Drawing.Graphics has no constructors, so I cannot create an instance such as:
System.Drawing.Graphics lineDrawer = new System.Drawing.Graphics();
How can I draw lines on a bitmap?
|
|
|
|
|
Klazen wrote: however this apparently only works with forms.
What makes you say that ?
Klazen wrote: I get an error saying that I must create an object instance to use this
Yes.
Klazen wrote: How can I draw lines on a bitmap?
Graphics graphics = Graphics.FromBitmap(myBitmap);
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you very much
I say that because the only working instance of Graphics I found was through a form, such as using it to draw lines on a form.
|
|
|
|
|
Ah, sure, because in the paint event, it's been created for you.
A lot of .NET classes use static factory methods instead of constructors, that's always something that's good to look for, in that scenario.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello comrades !!! I need your help. Here is what we have:
We have a jpg image that contains gray background and a lot of white eggs on it. We need to get the number of eggs and the size of each eggs. (i think in pixels).
How can i do it ?
The hardest problem is to get the whole egg (To mark the edges) and smart divide screen into some parts, for easiest count.
Thanks for help.
One nation - underground
|
|
|
|
|
Sounds like a school question. You'll never learn by immediately hoping on the forums and asking such a broad question. Instead start writing code and when you hit smaller stumbling blocks along the way, then we can help!
|
|
|
|
|
Interesting problem. Probably a lot easier than you think, however. Start with my image processing articles, for how to access the pixels of a bitmap. Then, just think it through.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello!
I have a question: I want to send signals from my pc to a µC via Ethernet!
PC sends signal via ethernet to a ethernet/RS232 changer and then to the µC!
I have problems to understand how to speak with the changer...
What should I look for?
Had someone the problem before?
Thanks!
|
|
|
|
|
Your only hope is documentation on the RS232/Ethernet changer or an SDK. Your single best source of information would be the manufacturer of the device. This is so non-standard, it's very unlikely you'll find someone who has done it.
|
|
|
|
|
Hi,
basically an Ethernet-to-RS232C converter consists of a cable and a driver
(same is true for a USB-to-RS232C converter).
when installed properly the cable+driver turn the new RS232C plug into a regular serial
interface; you should be able to see it in the list of available ports, e.g. in a terminal
emulator program such as HyperTerminal.
And you should also be able to use the SerialPort class to access that serial port in
exactly the same way you would access a regular serial port (assuming your PC still has one).
The conclusion is: you never "speak" to your converter, its driver makes it fully transparant.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hmmm...I've never heard of these little things, and frankly, can only think of a couple of reasons to even use one.
Learn somet'in new every day...
|
|
|
|
|
Hi!
What is the best way of determining the TopMost and BottomMost visible rows in the datagrid (.NET 1.1)
Thanks
|
|
|
|
|
Hi,
I have a TextBox, and DataGrid on a form. TextBox has the focus, by pressing the PageDown key while in TextBox, I want the DataGrid to perform the PageDown functionality.
I know that I have to use SendMessage method, I am just no sure what parameters I have to pass for the Pagedown handler.
Any ideas?
Thank you.
|
|
|
|
|
For simplicities sake I have extracted the following example from a larger app.
I have a simple form that has a listBox (L1) and two textBoxes (T1 & T2) and a submit button (B1). I have created a dataset(D1) that currently only has one table(T1) in it. I use VS's designer to bind the contents of T1 to L1. I then use the Databindings properties of the textBoxes to respectively bind one of the columns of the table (T1) to each. This works fine. It allows me to select an item from L1 and the text in the textboxes change to reflect their respective columns.
Now I added a function to hadle the SelectedIndexChanged event of L1. For the sake of simplicity I just put a MessageBox in the function. When I change the text in one of the textboxes then click the B1 button I have a function that ends the current edit and updates the tableAdapter. The value gets updated in the db. Then something unexpected happens after the update. The SelectedIndexChanged event fires once for every row in DS.T1 (Maybe as the listBox refreshes). Should this happen? I thought the SelectedIndexChanged event only fired when a user clicks on an item in the listbox.
How can I get the SelectedIndexChanged event to only fire when an item in the listbox is clicked?
BTW - I am using VS2008b2
-Kevin
-- modified at 16:11 Wednesday 12th September, 2007
|
|
|
|
|
the question are:
i add this into a listview
string ett = "1";
string u = comboBox1.Text;
string q = textBox1.Text;
string w = textBox2.Text;
DateTime dt = DateTime.Now;
if (q.Length > 0 && w.Length > 0 && u.Length > 0)
{
if (this != null)
{
string time = dt.ToString("dd");
string name = this.textBox1.Text + time.ToString() + ett;
ListViewItem item = new ListViewItem(new string[] { u, name, dt.ToString(), this.textBox2.Text });
ListViewIns.Items.Add(item);
But string u and name can not be equal with something else in a .txt file
for example
string u = Online
name = k431121
And the .txt file look like this:
#
online
k431121
blah
blah
If they two string match with line[index +1] an line[index +2] then add +1 on k431121. So in this example they match it will add +1 and look like this
#
online
k431121
blah
blah
#
online
k431122
blah
blah
I have a code but it don´t want to work:
private List<string> Entries;
private void LoadEntries()
{
string key;
Entries=new List<string>();
foreach (ListViewItem item in listView1.Items)
{
key = string.Concat(item.SubItems[0], "@@", item.SubItems[1]);
if (!Entries.Contains(key))
Entries.Add(key);
}
}
private void PopulateListView(List<string> list)
{
LoadEntries();
listView1.View = View.Details;
listView1.Columns.Add("Kolumn1");
listView1.Columns.Add("Kolumn2");
listView1.Columns.Add("Kolumn3");
listView1.Columns.Add("Kolumn4");
listView1.Columns.Add("Kolumn5");
string Name,No,key;
int n;
for (int i = 0; i < list.Count; i += 5)
{
Name = list[i+1];
No = list[i + 2];
while(Entries.Contains(key = string.Concat(Name, "@@", No)))
{
n = Convert.ToInt32(No.Substring(No.Length - 1));
No = String.Concat(No.Substring(0, No.Length - 1), n + 1);
}
if (!Entries.Contains(key))
Entries.Add(key);
ListViewItem item = new ListViewItem(list[i]);
item.SubItems.Add(Name);
item.SubItems.Add(No);
item.SubItems.Add(list[i + 3]);
item.SubItems.Add(list[i + 4]);
listView1.Items.Add(item);
}
}
My question is: can you help me build this together..???
Thanks////
|
|
|
|
|
Can somebody give me a sample of GridView update? I dont want to update each row. Instead, I want to store all updates on the client side(using datatable)
and update the entire gridview checking if the records are different from the existing database. For update command, am using SQL stored proc.
Please give me a sample.
Thanks
|
|
|
|
|
You can use TableAdapter.Fill() Method to update DataGridView, assuming that DataGridView is bound to dataset, and it has BindingSource and TableAdapter.
|
|
|
|
|
as the subject,
I want to add hyperlink to datagridview column, the link can download pdf file, like IE effect.
looks a little bit hard?
if can leave me a demo code to download is a prefer.
god bless me,
tomorrow is my task deadline.
thanks a lot,
James Liu
|
|
|
|