|
Hmm, that seems not to work too..
Last thing, code from VS Help:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
public class Form1 : System.Windows.Forms.Form
{
private DataGridView dataGridView1 = new DataGridView();
private BindingSource bindingSource1 = new BindingSource();
private SqlDataAdapter dataAdapter = new SqlDataAdapter();
private Button reloadButton = new Button();
private Button submitButton = new Button();
[STAThreadAttribute()]
public static void Main()
{
Application.Run(new Form1());
}
public Form1()
{
dataGridView1.Dock = DockStyle.Fill;
reloadButton.Text = "reload";
submitButton.Text = "submit";
reloadButton.Click += new System.EventHandler(reloadButton_Click);
submitButton.Click += new System.EventHandler(submitButton_Click);
FlowLayoutPanel panel = new FlowLayoutPanel();
panel.Dock = DockStyle.Top;
panel.AutoSize = true;
panel.Controls.AddRange(new Control[] { reloadButton, submitButton });
this.Controls.AddRange(new Control[] { dataGridView1, panel });
this.Load += new System.EventHandler(Form1_Load);
this.Text = "DataGridView databinding and updating demo";
}
private void Form1_Load(object sender, System.EventArgs e)
{
dataGridView1.DataSource = bindingSource1;
GetData("select * from Customers");
}
private void reloadButton_Click(object sender, System.EventArgs e)
{
GetData(dataAdapter.SelectCommand.CommandText);
}
private void submitButton_Click(object sender, System.EventArgs e)
{
dataAdapter.Update((DataTable)bindingSource1.DataSource);
}
private void GetData(string selectCommand)
{
try
{
String connectionString =
"Integrated Security=SSPI;Persist Security Info=False;" +
"Initial Catalog=Northwind;Data Source=localhost";
dataAdapter = new SqlDataAdapter(selectCommand, connectionString);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
bindingSource1.DataSource = table;
dataGridView1.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
catch (SqlException)
{
MessageBox.Show("To run this example, replace the value of the " +
"connectionString variable with a connection string that is " +
"valid for your system.");
}
}
}
|
|
|
|
|
Hi
why are we using
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
in the code
Regards
Akhil.N.P
|
|
|
|
|
I tried the below code but it is not woking. What may be the problem.
MySqlDataAdapter dAdapter;
BindingSource bs = new BindingSource();
DataTable dTable = new DataTable();
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bs;
dataGridView1.AutoGenerateColumns = false;
}
private void button1_Click(object sender, EventArgs e)
{
string connString;
string query;
connString = ConfigurationSettings.AppSettings.Get("OEMProjLogDB").ToString().Trim();
query = "SELECT * FROM `Update`";
dAdapter = new MySqlDataAdapter(query, connString);
dTable.Locale = System.Globalization.CultureInfo.InvariantCulture;
dAdapter.Fill(dTable);
bs.DataSource = dTable;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
Akhil.N.P
|
|
|
|
|
hi,
But Here my datagrid contains comboxes and check boxes so when i do this blank rows ae filled.
Regards
Akhil.N.P
|
|
|
|
|
Why to put checkboxes into datagrid maually? If the column is type of bool , datagrid automatically put checkboxes into this column. And about comboboxes, the column should be then some type of enum or something alike.
And by the way, i think, that DataGridView is only in memory, it provides data to DataGrid , which is displayed. Standard DataGrid filling is creating DataGridView , set its DataSource to some DataSet table. Then set DataGrid 's DataSource to this DataGridView and you are done.
|
|
|
|
|
Thanks for the Answer. But my problem again persist, coz i am using MySQL database engine. In MySQL True and False is stored as TINYINT[1] so it behaves as integer (TRUE-1, FALSE-0). So how come the datagrid automaticaly put checkboxes into this column by taking 0 and 1.
Thanks & Regards
Akhil.N.P
|
|
|
|
|
ucMod[tabcnt].gridLineDataGridView1 is the datagridview ucMod[] is a userControl in which the grid is present
|
|
|
|
|
Hi,
I have an images app, which consists of 2 main sub-apps. The viewer and editor. Editor should be installed only on one PC, the viewer will be installed and used by many customers. The problem is, how to distribute new images created in editor to customers.
(I have tried my own solution, downloading up-to-date database (*.mdf), read modified items and download these items. But i wasn't able to overwrite customer's local db (and etc.), so this was wrong way.)
Then I thought I could use directly ClickOnce Update system. I took installation files created with VS2005 and with mage.exe I successfully added new images to application's manifest, signed it and the same did to deployment manifest. The problem is, when i add some images to app. manifest using mage.exe and raise version of app. and deploy manifests (with the same exe files), install / update doesn't download anything, just raise the local version. ClickOnce checked that there is new version, but because of that i didn't modify the exe, the hash stayed same and no download was done. Even that the manifest contains new image files. So, can i somehow force ClickOnce not to compare exe's hash and download modified related images? Or somehow change the exe so the hash-check will fail and the exe with images will be downloaded.
Thank you.
|
|
|
|
|
Hi folks,
I'm trying to get a little color animation working for a Border(ed)-area. The Border has a style defined like this:
<Border x:Name="border"
CornerRadius="0,4,4,0"
BorderBrush="#FFD2DAED"
BorderThickness="1">
<ContentPresenter TextBlock.Foreground="White" />
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFF6F9FD" Offset="0"/>
<GradientStop Color="#FFE4ECF6" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Border.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard Storyboard.TargetName="Border.BorderBrush"
Storyboard.TargetProperty="Color" >
<ColorAnimation
To="#FFD2DAED"
From="#FF000000"
Duration="0 :1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Border.Triggers>
</Border>
My guess is, that the TargetName-property of the storyboard is misgiven. What would be the right path?
When this is solved, I'd like to add an animation for the background (LinearGradienBrush). How can I set that path?
Thank's in advance for you help!
Regards,
Stevie
Greetings,
Stephan Eberle
hawke@deltacity.org
|
|
|
|
|
Nevermind! WPF is just great and I failed to see its greatness!
Use of ControlTemplate.Triggers solved my problem!
Greetings,
Stephan Eberle
hawke@deltacity.org
|
|
|
|
|
Hi, i am writing whats turning into quite a large (little) program that displays thumbnails (1 - 200) in a a form which also has a timer which activates a backgroundworker process which updates a listbox with info.
It all works fine untill i leave it minimized for an hour or so then the form is only visible in the taskbar (its icon) . Its as if its minimized but clicking it activates (the taskbar icon changes colour etc with focus) but it wont maximise.
If i use the taskmanager it says the program is 'Running' and by right clicking and selecting 'Maximise' the window will appear maximised but all the controls on the form arent displaying the images or listboxes, its as if the application has crashed. I need to 'end task' to exit the program the menus and close (x) icon dont respond.
Like i said the application runs fine if i interact with it, it appears to only 'crash to taskbar' if i leave it unattended for an hour or so.
Any ideas where i might start looking to resolve this?
Thanks
modified on Friday, September 12, 2008 6:54 PM
|
|
|
|
|
teddycrew wrote: Any ideas where i might start looking to resolve this?
If by ideas you mean guesses, my first guess would be the fact that you are using multiple threads. Most novice multi-threading developers create errors related to the threading because they lack the knowledge. Things like the BackgroundWorker class just make it worse because people think they can just drag and drop and don't need to understand the complex aspects of multi-threading. It just ain't so. Then the next thing you know, strange behavior.
led mike
|
|
|
|
|
Hi, thanks for reply, i know threads can introduce 'strange behaviors' but i have followed the msdn articles about them, like only interacting with form controls in the 'Workcompelted' event. anyhow i updated the above because this crashing behaviour is only occuring when the form is left minmized.
|
|
|
|
|
I am using dot net 2003 but now want to move on dot net 2005
when I start installing through CD I got a error
"Suite Integration Toolkit Executable has encountered a problem and needs to close. We are sorry for the inconvenience."
can any one resolve my problem. Is it necessary to remove 2003 first? I am installing on windows XP Pro .
Pls help me.
|
|
|
|
|
You don't need to remove 2003. You do need to have a minimum of XP SP2 installed though, and this is a common cause of this problem - not having it installed.
|
|
|
|
|
Hi!
I am facing problem in INSERT statement of SQL 2005 express. Actually I want to save data from one table to another using SQL statement. I want to do something like that, when I will press Create button from DataGride Column. The whole data of that row of that Registration table will insert in some another table like Account. I have tried but I cannot do it. Please help me if anybody can.
|
|
|
|
|
First of all, there's a SQL forum for SQL related questions. Second, you need to provide a lot more information than this - this is too vague. Try to break it down a bit, but you need to do multiple inserts.
|
|
|
|
|
For future reference, there is a SQL Forum on this site. You might have better luck there.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi all,
I am currently working with .Net framework 2.0 with visualstudio 2005.
But now i want to move to .net framework 3.5 with visualstudio 2008.
I am very new to this.so can any one help me how to installation procedure for this.
Quick response will be appreciable
regards..
Y.A.Krishna Prasad
fttyhtrhyfytrytrysetyetytesystryrty
|
|
|
|
|
Download or purchase VS 2008 and the run the setup - then answer some questions about what and where you want things installing. I'm not trying to be funny here, but I really can't see what problem you expect beyond that.
|
|
|
|
|
|
I have been working on a custom DataGridView which will be used in unbound mode. I have had a problem where, if the user edits a cell with text longer than allowed by the database, the text is truncated when it is saved back to the database.
The following OnCellValidating method is my attempt to validate the length of cell text. The idea is that if the new text is longer than allowed by the database, the cell changes its background color, a message is given and the user cannot proceed off the cell until valid data is provided. Here is the code:
1: Protected Overrides Sub OnCellValidating(ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs)
2: Dim Col As DataGridViewColumn = Me.Columns(e.ColumnIndex)
3: Dim FD As FieldDescriptor = TryCast(Col.Tag, FieldDescriptor)
4:
5: If Me.Rows(e.RowIndex).Cells(e.ColumnIndex) IsNot Nothing Then
6: Me.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = Col.CellTemplate.Style.BackColor
7: End If
8:
9: If Col.ReadOnly OrElse _
10: (FD.DescriptionRow Is Nothing OrElse FD.DescriptionRow.ColumnMetadata Is Nothing) Then
11: Exit Sub
12: End If
13:
14: Dim CM As DbColumnInfo = FD.DescriptionRow.ColumnMetadata
15: Dim MaxSize As Integer = CM.MaxLength
16: If e.FormattedValue.ToString.Length > MaxSize Then
17: Me.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = ColorConstants.MissingData
18: Me.InvalidateCell(e.ColumnIndex, e.RowIndex)
19: ShowMsg(String.Format("This field is limited to {0} characters.", MaxSize), _
20: MsgBoxIcon.Critical, "Text is too long!")
21: e.Cancel = True
22: End If
23: End Sub
The class FieldDescriptor is filled in an earlier phase; its ColumnMetadata property holds a class with the column's metadata such as the varchar size. ShowMsg is a standard interface for providing feedback to the user in various application setups.
The problems I'm having are in trying to set the cell's style property. The change in the background color made in line 17 is never visible, even though I am calling InvalidateCell in the very next line. None of the other invalidate routines work, either. Worse, setting the cell's Style.BackGround property sets CellTemplate.Style.BackColor for the entire column, making my efforts to reset the cell's background to the default color in lines 5-7 pointless.
Ok, fine, use the ErrorText property. Problem is, if I use e.Cancel = True then the error icon is never rendered, leaving the user with no feedback as to which cell has the error. If I do not set the Cancel property, then error icon is rendered; however, the validation is considered good and the database update (along with the truncation of data) proceeds.
Any suggestions on how to proceed?
|
|
|
|
|
Hi all. I'm developing a solution which is designed to give the end-user a semi-customisable workflow solution where they can define the steps an item need to take through a workflow before it becomes "signed-off". There are several paths which an item can take, and several types of item which may enter the system. It's essentially a bug-tracker system with some bells and whistles on it. I'm wondering if WF is the technology to use. From browsing the documentation it seems as though there's a way to save the state of a workflow and not only that, it's possible to override the default implementation and write my own persistence layer. I'm at the stage where I need to commit to a platform with this, and I'd like some input from anyone who has used, or considered using, this option. Essentially what we're talking about is giving the user a very small subset of the functionality you get with using WF in Visual Studio. They don't need the works, there are fairly small custom parameters. And I need to make this happen fast, like in the next month.
Has anyone out there blooded themselves with a real-world WF project, and have they any input on this?
|
|
|
|
|
|
Hello everyone,
I'm a student of final yr telecom engg. For sometime now, I have been seeking advise/expertise in implementing customized voip applications, which is my project for the final semester.
I plan to develop a voip application which will basically be fielded on a LAN(i.e. no external VOIP provider). This voip network will comprise of a few clients(10 to 20) having either ipphone or analog phones with ATA, enabling voice communication among each other. In addition to this I want to develop a gateway which will be an interface between this network and an external network comprising of hand held radios. This gateway would facilitate voip calls between any client on the network to a hand-held radio operator.
I have a feeling that SIP would be an ideal choice, but I am not able to choose a platform for developing such an application. I have looked into Asterix(trixbox) which was advised to me by some friends...but frankly i am not very comfortable with Linux.
Is there something available in .NET or could any one advise any other platform?
Can anyone provide some help?
|
|
|
|