Click here to Skip to main content
16,005,181 members
Home / Discussions / C#
   

C#

 
GeneralCall is rejected by callee exception Pin
Asuri8-Dec-04 5:38
Asuri8-Dec-04 5:38 
GeneralTcp Client /server synchronous read Pin
jayanth sai8-Dec-04 4:51
jayanth sai8-Dec-04 4:51 
GeneralRuntime Error 406 Pin
sharon_s8-Dec-04 4:25
sharon_s8-Dec-04 4:25 
Generaloverloading == and != Pin
Jan R Hansen8-Dec-04 4:08
Jan R Hansen8-Dec-04 4:08 
GeneralRe: overloading == and != Pin
Daniel Turini8-Dec-04 5:21
Daniel Turini8-Dec-04 5:21 
GeneralRe: overloading == and != Pin
Jan R Hansen8-Dec-04 11:41
Jan R Hansen8-Dec-04 11:41 
GeneralRe: overloading == and != Pin
Skynyrd8-Dec-04 23:51
Skynyrd8-Dec-04 23:51 
GeneralDataGrid formatting Pin
wtdoor19658-Dec-04 3:27
wtdoor19658-Dec-04 3:27 
I am trying to use a datagrid with columns of different width. I have found several methods posted on various sites, but unfortunately am unable to make any of them work. The following code seems to be the most straightforward, but none of the formatting is actually applied to the datagrid.

What am I missin?

private void FormView_Load(object sender, System.EventArgs e)
{
string connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=reminder.mdb";
//string query ="SELECT Date,Time,Message,TicklerDate,TicklerTime FROM Ticklers";
string query ="SELECT * FROM Ticklers";
// Initialize the connection using the connection string
conn = new OleDbConnection(connection);

// Open the db connection
conn.Open();

//Initiate the OleDbDataAdapter using the SQL select commmand on the db connection
adapter=new OleDbDataAdapter(query,conn);

// Initiate and fill the dataset
ds = new DataSet();
//initiate the datatable
adapter.Fill(ds,"Customers");
dt = ds.Tables[0];
// Get the database schema
adapter.FillSchema(dt, SchemaType.Source);


conn.Close();

// Format the data grid
DataGridTableStyle ts = new DataGridTableStyle();
this.dataGrid1.TableStyles.Clear();

//ts.MappingName="Ticklers";
ts.MappingName=dataGrid1.DataMember;

DataGridTextBoxColumn column1 = new DataGridTextBoxColumn();
column1.MappingName="Index";
column1.HeaderText="Index";
column1.Width = 0;
ts.GridColumnStyles.Add(column1);

DataGridTextBoxColumn column2 = new DataGridTextBoxColumn();
column2.MappingName="Date";
column2.HeaderText="Event Date";
column2.Width = 75;
ts.GridColumnStyles.Add(column2);

DataGridTextBoxColumn column3 = new DataGridTextBoxColumn();
column3.MappingName="Time";
column3.HeaderText="Event Time";
column3.Width = 75;
ts.GridColumnStyles.Add(column3);

DataGridTextBoxColumn column4 = new DataGridTextBoxColumn();
column4.MappingName="Message";
column4.HeaderText="Description";
column4.Width = 150;
ts.GridColumnStyles.Add(column4);

DataGridTextBoxColumn column5 = new DataGridTextBoxColumn();
column5.MappingName="TicklerTime";
column5.HeaderText="Tickler Time";
column5.Width = 75;
ts.GridColumnStyles.Add(column5);

DataGridTextBoxColumn column6 = new DataGridTextBoxColumn();
column6.MappingName="TicklerDate";
column6.HeaderText="Tickler Date";
column6.Width = 75;
ts.GridColumnStyles.Add(column6);

dataGrid1.TableStyles.Add(ts);

// Bind the datatable to the datagrid control
this.dataGrid1.DataSource=dt;

// Show the datagrid
this.dataGrid1.Visible=true;

}Confused | :confused:

ngb
GeneralBitmap Rendering speed Pin
Tristan Rhodes8-Dec-04 3:17
Tristan Rhodes8-Dec-04 3:17 
GeneralRe: Bitmap Rendering speed Pin
Daniel Turini8-Dec-04 5:32
Daniel Turini8-Dec-04 5:32 
GeneralRe: Bitmap Rendering speed Pin
Tristan Rhodes8-Dec-04 13:04
Tristan Rhodes8-Dec-04 13:04 
GeneralRe: Bitmap Rendering speed Pin
Tristan Rhodes9-Dec-04 4:06
Tristan Rhodes9-Dec-04 4:06 
GeneralRe: Bitmap Rendering speed Pin
Daniel Turini9-Dec-04 4:26
Daniel Turini9-Dec-04 4:26 
GeneralRe: Bitmap Rendering speed Pin
Tristan Rhodes9-Dec-04 5:21
Tristan Rhodes9-Dec-04 5:21 
GeneralRe: Bitmap Rendering speed Pin
Daniel Turini9-Dec-04 7:18
Daniel Turini9-Dec-04 7:18 
GeneralTextChanged vs Click Pin
realmontanakid8-Dec-04 2:23
realmontanakid8-Dec-04 2:23 
GeneralRe: TextChanged vs Click Pin
Stefan Troschuetz8-Dec-04 2:40
Stefan Troschuetz8-Dec-04 2:40 
GeneralRe: TextChanged vs Click Pin
realmontanakid8-Dec-04 4:14
realmontanakid8-Dec-04 4:14 
GeneralRe: TextChanged vs Click Pin
Stefan Troschuetz8-Dec-04 4:31
Stefan Troschuetz8-Dec-04 4:31 
GeneralRe: TextChanged vs Click Pin
realmontanakid8-Dec-04 4:59
realmontanakid8-Dec-04 4:59 
GeneralRe: TextChanged vs Click Pin
Dave Kreskowiak8-Dec-04 4:50
mveDave Kreskowiak8-Dec-04 4:50 
GeneralRe: TextChanged vs Click Pin
realmontanakid8-Dec-04 5:19
realmontanakid8-Dec-04 5:19 
GeneralRe: TextChanged vs Click Pin
Stefan Troschuetz9-Dec-04 21:59
Stefan Troschuetz9-Dec-04 21:59 
QuestionHow to create an array of textboxes with the disigner ? Pin
rgcolli8-Dec-04 2:22
rgcolli8-Dec-04 2:22 
GeneralBig DB problem Pin
Zamolxes8-Dec-04 1:51
Zamolxes8-Dec-04 1:51 

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.