Click here to Skip to main content
15,886,518 members
Home / Discussions / C#
   

C#

 
GeneralDLL Help Pin
goldoche5-May-04 5:54
goldoche5-May-04 5:54 
GeneralRe: DLL Help Pin
Heath Stewart5-May-04 6:59
protectorHeath Stewart5-May-04 6:59 
GeneralXmlDocument, SOAP& Namespaces Pin
MrEyes5-May-04 5:40
MrEyes5-May-04 5:40 
GeneralRe: XmlDocument, SOAP& Namespaces Pin
Heath Stewart5-May-04 5:44
protectorHeath Stewart5-May-04 5:44 
GeneralRe: XmlDocument, SOAP& Namespaces Pin
MrEyes5-May-04 5:58
MrEyes5-May-04 5:58 
GeneralRe: XmlDocument, SOAP& Namespaces Pin
Heath Stewart5-May-04 7:10
protectorHeath Stewart5-May-04 7:10 
GeneraldataGridTextBoxColumn textBox Pin
blankg5-May-04 5:16
blankg5-May-04 5:16 
Generalc# Listbox help Pin
John Baird5-May-04 4:48
John Baird5-May-04 4:48 
I'm pulling out what little remaining hair I have again. I have a list box with 8 items, the selected item is highlighted at the top of the list. I press a button (cmdMoveDown) and wish to move the selected item 1 item down the list.

I tried this:

public void MoveDown()<br />
{<br />
     int index = this.lstSelected.SelectedIndex;<br />
     int newindex = index + 1;<br />
<br />
     DataTable dtSelect = (DataTable)this.lstSelected.DataSource;<br />
     DataRow dr = dtSelect.Rows[index];<br />
<br />
     dtSelect.Rows.Remove(dr);<br />
     dtSelect.Rows.InsertAt(dr, newindex);<br />
}


this removes the item at index 0 just fine. But the insert doesn't happen and there is a blank line at the bottom of the list.


then i tried this variation:


public void MoveDown()<br />
{<br />
     int index = this.lstSelected.SelectedIndex;<br />
     int newindex = index + 1;<br />
<br />
     DataTable dtSelect = (DataTable)this.lstSelected.DataSource;<br />
     DataRow dr = dtSelect.Rows[index];<br />
     DataRow drNew = dtSelect.NewRow();<br />
<br />
     foreach(DataColumn dc in dtSelect.Columns)<br />
        drNew[dc.ColumnName] = dr[dc.ColumnName];<br />
<br />
     dtSelect.Rows.Remove(dr);<br />
     dtSelect.Rows.InsertAt(drNew, newindex);<br />
}


this variation removed the selected item and added the new row at the end of the list rather than at new index.

I tried various permutations of this code and could get nothing to work. Any suggestions?
GeneralRe: c# Listbox help Pin
Heath Stewart5-May-04 4:59
protectorHeath Stewart5-May-04 4:59 
GeneralRe: c# Listbox help Pin
John Baird5-May-04 9:21
John Baird5-May-04 9:21 
GeneralRe: c# Listbox help Pin
Heath Stewart5-May-04 9:31
protectorHeath Stewart5-May-04 9:31 
GeneralCreating &amp; Using DLL's Pin
Lakshmikanthan5-May-04 4:42
Lakshmikanthan5-May-04 4:42 
GeneralRe: Creating &amp; Using DLL's Pin
Heath Stewart5-May-04 4:55
protectorHeath Stewart5-May-04 4:55 
GeneralDiffgrams and Web Services Pin
MrJJKoolJ5-May-04 3:51
MrJJKoolJ5-May-04 3:51 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 4:13
protectorHeath Stewart5-May-04 4:13 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:08
MrJJKoolJ5-May-04 5:08 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 5:16
protectorHeath Stewart5-May-04 5:16 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:23
MrJJKoolJ5-May-04 5:23 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 5:25
protectorHeath Stewart5-May-04 5:25 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:51
MrJJKoolJ5-May-04 5:51 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 7:13
protectorHeath Stewart5-May-04 7:13 
Generalsharing new Instance of class across the application Pin
Adi Narayana5-May-04 3:08
Adi Narayana5-May-04 3:08 
GeneralRe: sharing new Instance of class across the application Pin
Stefan Troschuetz5-May-04 3:32
Stefan Troschuetz5-May-04 3:32 
GeneralPopulating a combobox with data from a rondom access file Pin
mikeyb255-May-04 3:06
mikeyb255-May-04 3:06 
GeneralRe: Populating a combobox with data from a rondom access file Pin
..Hubert..5-May-04 3:24
..Hubert..5-May-04 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.