Click here to Skip to main content
15,885,244 members
Home / Discussions / C#
   

C#

 
GeneralRe: Scrolling on mouse down/move Pin
MrEyes21-Jan-04 12:53
MrEyes21-Jan-04 12:53 
GeneralRe: Scrolling on mouse down/move Pin
Heath Stewart21-Jan-04 8:06
protectorHeath Stewart21-Jan-04 8:06 
GeneralRe: Scrolling on mouse down/move Pin
MrEyes22-Jan-04 0:15
MrEyes22-Jan-04 0:15 
GeneralRe: Scrolling on mouse down/move Pin
Heath Stewart22-Jan-04 4:24
protectorHeath Stewart22-Jan-04 4:24 
GeneralAdding Column to a ListView Pin
Guinness4Strength21-Jan-04 5:37
Guinness4Strength21-Jan-04 5:37 
GeneralRe: Adding Column to a ListView Pin
Heath Stewart21-Jan-04 5:52
protectorHeath Stewart21-Jan-04 5:52 
GeneralRe: Adding Column to a ListView Pin
Guinness4Strength21-Jan-04 5:57
Guinness4Strength21-Jan-04 5:57 
GeneralRe: Adding Column to a ListView Pin
Heath Stewart21-Jan-04 7:50
protectorHeath Stewart21-Jan-04 7:50 
What I read - also in MSDN but regarding the List-View common control which ListView encapsulates - described what I said before. A slight discrepency somewhere, but it really matters not.

The following code worked fine for me (both the commented source, and the uncommented):
using System;
using System.Drawing;
using System.Windows.Forms;

public class Test : Form
{
  public static void Main()
  {
    Application.Run(new Test());
  }

  public Test()
  {
    ListView lv = new ListView();
    Controls.Add(lv);
    lv.Dock = DockStyle.Fill;
    lv.View = View.Details;

    foreach (string s in new string[] {"Code", "Project", "Is", "Awesome"})
    {
//    ColumnHeader header = new ColumnHeader();
//    header.Text = s;
//    header.Width = -2;
//    lv.Columns.Add(header);
      lv.Columns.Add(s, -2, HorizontalAlignment.Left);
    }
  }
}
I didn't catch before that you were using DataColumn.ToString. There's the problem. If you look at the documentation for DataColumn.ToString (which it overrides, but be careful because classes that don't override it and inherit from Object.ToString will return their Type as string), you'll see that it returns DataColumn.Expression, which is used to filter and calculate values. Instead, use DataColumn.Caption. If the Caption is not set, the ColumnName is returned. If you prefer, you can set the Caption when creating a strongly-typed DataSet, or you can use the database column name or an ALIAS.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: Adding Column to a ListView Pin
Guinness4Strength22-Jan-04 8:33
Guinness4Strength22-Jan-04 8:33 
GeneralRe: Adding Column to a ListView Pin
Heath Stewart22-Jan-04 9:26
protectorHeath Stewart22-Jan-04 9:26 
GeneralRe: Adding Column to a ListView Pin
Guinness4Strength22-Jan-04 9:33
Guinness4Strength22-Jan-04 9:33 
GeneralRe: Adding Column to a ListView Pin
Heath Stewart22-Jan-04 9:39
protectorHeath Stewart22-Jan-04 9:39 
GeneralRe: Adding Column to a ListView Pin
Guinness4Strength22-Jan-04 9:45
Guinness4Strength22-Jan-04 9:45 
GeneralRe: Adding Column to a ListView Pin
Heath Stewart22-Jan-04 9:49
protectorHeath Stewart22-Jan-04 9:49 
GeneralRe: Adding Column to a ListView Pin
Guinness4Strength22-Jan-04 9:57
Guinness4Strength22-Jan-04 9:57 
GeneralUser friendly error Pin
Anonymous21-Jan-04 4:47
Anonymous21-Jan-04 4:47 
GeneralRe: User friendly error Pin
Alex Korchemniy21-Jan-04 4:54
Alex Korchemniy21-Jan-04 4:54 
GeneralRe: User friendly error Pin
Mazdak21-Jan-04 5:04
Mazdak21-Jan-04 5:04 
GeneralRe: User friendly error Pin
eggie521-Jan-04 12:26
eggie521-Jan-04 12:26 
GeneralCustom Panel Pin
ernst wolthaus21-Jan-04 4:24
ernst wolthaus21-Jan-04 4:24 
GeneralRe: Custom Panel Pin
Mazdak21-Jan-04 4:46
Mazdak21-Jan-04 4:46 
GeneralRe: Custom Panel Pin
ernst wolthaus21-Jan-04 7:46
ernst wolthaus21-Jan-04 7:46 
GeneralRe: Custom Panel Pin
Heath Stewart21-Jan-04 5:34
protectorHeath Stewart21-Jan-04 5:34 
GeneralRe: Custom Panel Pin
Jose Fco Bonnin21-Jan-04 5:52
Jose Fco Bonnin21-Jan-04 5:52 
GeneralRe: Custom Panel THANKS! Pin
ernst wolthaus21-Jan-04 7:42
ernst wolthaus21-Jan-04 7:42 

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.