Search Results

Search found 2511 results on 101 pages for 'datagridview trick'.

Page 5/101 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • DatagridView loses current edit on Background update

    - by yoni.s
    Here's my problem : I have a DataGridView bound to a BindingList of custom objects. A background thread is constantly updating a value of these objects. The udpates are showing correctly, and everything is fine except for one thing - If you try to edit a different field while the background-updated field is being updated, it loses the entered value. Here is a code sample that demonstrates this behavior: (for new form, drop a new DataGridView on:) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication2 { public partial class Form1 : Form { private BindingList<foo> flist; private Thread thrd; private BindingSource b; public Form1() { InitializeComponent(); flist = new BindingList<foo> { new foo(){a =1,b = 1, c=1}, new foo(){a =1,b = 1, c=1}, new foo(){a =1,b = 1, c=1}, new foo(){a =1,b = 1, c=1} }; b = new BindingSource(); b.DataSource = flist; dataGridView1.DataSource = b; thrd = new Thread(new ThreadStart(updPRoc)); thrd.Start(); } private void upd() { flist.ToList().ForEach(f=>f.c++); } private void updPRoc() { while (true) { this.BeginInvoke(new MethodInvoker(upd)); Thread.Sleep(1000); } } } public class foo:INotifyPropertyChanged { private int _c; public int a { get; set; } public int b { get; set; } public int c { get {return _c;} set { _c = value; if (PropertyChanged!= null) PropertyChanged(this,new PropertyChangedEventArgs("c")); } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion } } So, you edit column a or b, you will see that the column c update causes you to lose your entry. Any thoughts appreciated.

    Read the article

  • Copy and paste into a DataGridView cell (C#)

    - by DaBomb
    I need to be able to copy a name or names from one application (using the normal copy commands) and then be able to double click the text cell in a DataGridView to paste the data into the grid cell. Any ideas on how to accomplish this? I am attempting to minimize keyboard use for this functionality.

    Read the article

  • DataGridView Autosize but restrict max column size

    - by aaginor
    Hi folks, in my C# 4.0 Application, I have a DataGridView to display some data. I want the Columns size accordingly to the content, so I set the AutoSizeColumnsMode to AllCellsExceptHeader. But I want to restrict the columns to grow beyond a certain value. There is a MinimumWidth Property ... but unfortunately no MaximumWidth Property. Any ideas how to solve this? Thanks in advance, Frank

    Read the article

  • can we use both custom button and inbuilt button in datagridview

    - by Srikanth Mattihalli
    HI all, I am using Datagridview in asp.net. I have used custom buttons of up and down in the datagridview along with edit,delete and paging options. I am handling the up down buttons by raising events in rowcommand and the code is as below string command = e.CommandName; Response.Write(e.CommandArgument.ToString()); int index = Convert.ToInt32(e.CommandArgument.ToString()); int count = GridView1.Rows.Count; int keyValue = Convert.ToInt32(GridView1.Rows[index].Cells1.Text); string value = GridView1.Rows[index].Cells[4].Text; SqlConnection conn = new SqlConnection(SqlDataSource1.ConnectionString); SqlCommand cmd = new SqlCommand(); if (command == "up") { if (index > 0) { index = index - 1; int keyValue1 = Convert.ToInt32(GridView1.Rows[index].Cells[1].Text); string value1 = GridView1.Rows[index].Cells[4].Text; cmd.Connection = conn; cmd.CommandText = "UPDATE [category] SET [order_id] = '" + value + "' WHERE [category_id]=" + keyValue1 + ";UPDATE [category] SET [order_id] = '" + value1 + "' WHERE [category_id]=" + keyValue + ";"; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } else if (command == "down") { if (index < count - 1) { index = index + 1; int keyValue1 = Convert.ToInt32(GridView1.Rows[index].Cells[1].Text); string value1 = GridView1.Rows[index].Cells[4].Text; cmd.Connection = conn; cmd.CommandText = "UPDATE [category] SET [order_id] = '" + value + "' WHERE [category_id]=" + keyValue1 + ";UPDATE [category] SET [order_id] = '" + value1 + "' WHERE [category_id]=" + keyValue + ";"; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } Response.Redirect("Default.aspx"); Designer file " DeleteCommand="DELETE FROM [category] WHERE [category_id] = @category_id" InsertCommand="INSERT INTO [category] ([categoryname], [navigation_url], [order_id]) VALUES (@categoryname, @navigation_url, @order_id)" SelectCommand="SELECT * FROM [category] order by order_id" UpdateCommand="UPDATE [category] SET [categoryname] = @categoryname, [navigation_url] = @navigation_url, [order_id] = @order_id WHERE [category_id] = @category_id" After this my edit,delete and paging is not working bcoz of event conflicts. Can anyone plz help me on this, so that i will be able to use both custom buttons(up and down) and edit,delete and paging features.

    Read the article

  • No cursor when resizing datagridview

    - by anya
    When i'm trying to resize datagridview columns the resize cursor appears only when i roll over header. However, when i roll over in between cells, resize cursor doesn't show at all. I have noticed if i set ColumnHeadersVisible = false it fixes the problem and i see resize cursor between columns. However, i need header to be visible, any idea how to make it work all together?

    Read the article

  • Acessing Datagridview

    - by Shiny
    One of my form has dropdownlist.when i select the item.textbox holds the value of 2.0. that has to be applied to my datagridview in cell content 11.with other records that will be pulled from access database. but cell content 11 wil have data when other records are pulled. how can i achieve this? thanks in advance

    Read the article

  • C# datagridview right click select row and show menu to delete it

    - by Data-Base
    Hello, I have few columns in my DataGridView, and there is data in my rows, I saw few solutions in here, but I can not combine them! simply a way to right-click on a row it select the whole row and show a menu with an option to delete the row and when the option selected it will delete the row I made few attempts but none is working and it looks messy any suggestions? cheers

    Read the article

  • datagridview rowsremoved event gets called every time data loads

    - by Nilotpal Das
    The datagridview rowsremoved event gets called every time the data gets loaded. It also makes sense to a certain extent that every time the data loads, the existing rows are removed. so technically the event should get called. But how do i differenciate that from the actual delete button getting pressed. I don't think the key events should be used, that wouldn't be a clean approach. Any help will be most appreciated.

    Read the article

  • No cursor when resizing datagridview c#

    - by anya
    HI guys, When im trying to resize datagridview columns the resize cursor appears only when i roll over header. However, when i roll over in between cells, resize cursor doesnt show at all. I have noticed if i set ColumnHeadersVisible = false it fixes the problem and i see resize cursor between columns. However, i need header to be visible, any idea how to make it work all together? Thanks!

    Read the article

  • how to implement undo operation in datagridview

    - by ush
    Hi, I have created one application in c#.net.Using this application we can update datagridview,now i need to implement undo in it plz give me some ideas. private void button29_Click(object sender, EventArgs e) { Datatable dt; dt.RejectChanges(); } using above code i can do undo before updating. but i need a undo feature as in word plz suggest me thanks in advance

    Read the article

  • Visual marker when moving rows on DataGridView

    - by BlueRaja
    Users drag rows up and down in my DataGridView. I have the dragging logic down-pat, but I'd like there to be a dark marker indicating where the row will be placed after I let go of the mouse. (I've seen this in 1000 places before, but can't seem to find an example right now) Does anyone know how I'd go about doing this? Is this built-in, or would I have to draw my own marker (if so, how do I do that)? Thanks!

    Read the article

  • DataGridView fails SelectedCells property

    - by ghiboz
    Hi! in my project I have 3 DataGridView and I need to retrieve the SelectedCells of the grid in 2 grids this works fine, but in one ( and the code is exactly the same of the other 2) the grid.SelectedCells.Count is 1 but If I go in the inspector to view which cell is selected, the result is 0,0... thanks

    Read the article

  • Add/Edit Columns in DataBound DataGridView

    - by Dave
    I've got a datagridview that is databound from a database table. How do I: a) Edit the displayed value for a column using the values from other columns in the row? (For example, display a URL like: <a href="/url?param=columnA">columnB</a> where columnA is the value from column A and columnB is the value from columnB) b) Add an additional column using values from the other columns (similar to a.)

    Read the article

  • How to view a Column Name in listbox by selecting the Column in DataGridView

    - by Umair
    Hey, im working on a project and i have to get the name(header text) of selected column in my listbox or textbox from datagridview, when i select any column it shows the name of that column in textbox or listbox.. i'll be very thankful to if you guys kindly help me out in this matter.. im trying to use the code on DataGridViewHeaderClickEvent "textBox1.Text=dataGridView1.SelectedColumns.ToString();"

    Read the article

  • Format of DataGridView value

    - by Vadim
    I have a DataGridView which is filling from Table in SQL Server Database. One of it's columns is "price". Type of column in DGV is automatically sets as Decimal. In some cases I need to write in cells of this column text like "none", instead of price. How can I do it? DGV.Item("price", 0).Value = "none" doesn't work, because of decimal type of a cell.

    Read the article

  • C#: Deal with xml, treeview datagridview and datatables

    - by renulren
    Hi all, I am working on a project that pulls data out of an xml files and also uses a tree-grid combination in order to display the data. For example depending on the selected treeview node, the datagridview will display only the records related to that node. What do you think it would be the appropriate approach in dealing with this? Thanks!

    Read the article

  • How can i create a context menu in c# in a datagridview

    - by lanoxx
    Hi all, I have written a datagridview with a couple of columns to store data of a product, now i want to be able to right click any row and have a context menu appear with the options delete and copy. Copy should have the same functionality as if I press Ctrl+C. Any help would be appreciated. Im using C# and WinForms. I have never done context menus before, so I would be thank full for any hint or link to further readings. Cheers

    Read the article

  • Center current record in DataGridView

    - by Max
    When programmatically changing the current record in the DataGridView is it possible to make it in such way that this record would be centered (vertically) in the grid? When I change the current record it is shown either as the top row or as the bottom row. I'd like it to be in the middle. Would this be possible/simpler in WPF?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >