In datagridview it will be possible every time I go down a column in the cell, specify the type of object I want. Example in row one I want combobox, in second row I need textbox, in third row check
Each column type has a default cell type but you can put any cell you want in any column. You can simply create a cell and place it by indexing the grid, e.g.
myDataGridView(columnIndex, rowIndex) = New DataGridViewTextBoxCell
You should choose the column type based on the most common cell type and then create just the cells that need a different type.
Related
My Access database has MainTable that includes, among other fields, Event Description.
I get the Event Description from another table, EventTable, that has two fields, EventID and Event Description
My form has a combobox that lets users select the "Event Description", and that works okay. But in my VBA code, I have to be able to capture the EventID itself.
Is there a way to do that without putting an "EventID" control on the form? (Even an invisible one?)
Simply use a hidden column on the combobox which you can set up via the control wizard. However, specific design steps include:
Under Data tab of Property Sheet, use EventID as the Control Source of combo box. This assumes form is bound to a record source.
Under Data tab of Property Sheet, use a two column SQL query that includes EventID (hidden column) and EventDescription (displayed column) as Row Source with Row Source Type being Table/Query. You can add more columns with corresponding adjustments to #3 below. Be sure that 1 is used for Bound Column or whatever column position aligns to EventID.
SELECT EventID, EventDescription
FROM Events
Under Format tab of Property Sheet, use 2 (or more for every column in query) for Column Count and zero for first item and non-zero for second or more items in Column Widths (e.g., 0"; 2"). Ideally, the widths add up to the total width of combo box.
Altogether, above will hide EventID in combobox but show to users EventDescription and any choice selected will return the corresponding EventID value.
I'm making an Excel sheet to keep track of some activities. The thing is that I have 2 cells that are date type; I want the third cell to subtract the them to get the time that the x person spent on the activity.
I know that if I type =A2-A1 it's going to give me what I want, but, since its going to be a big Excel sheet with lots of records, I don't want to input the same formula for each row just changing the row number.
Is there a way to make Excel detect the row that the user is inputing data in and then make the requested formula to get the time?
you can turn your data range into a table by highlighting the range and going to the insert tab and clicking table. Then when you type the formula into the first cell and click in the cells when selecting instead of typing it out, you will notice that it is using the column names instead, also it will automatically fill the column with the new formula. That would be my suggestion.
I have number of columns to be in always edit mode so i am applying alwaysEditing=true for No of Columns the Pointer is always focusing the last column even if i select any other column in the Grid.
I need a solution that whenever i click any column the Pointer should focus on the selected instead of last column in the Grid.
I have a datagridview that is only two or three rows long. It has 7 text columns, one for each day of the week (Monday - Sunday). I'm creating a scheduler, so basically on the left side I have added text to the row headers to assign to it. I.e. Enabled (let's say for Tuesday), start time and end time. This allows the user to schedule as need be.
Here's a picture of it right now:
What I want to do is possibly change the enabled row, or the start/end time to a particular type. So the enabled will be a checkbox and the start/end times will be drop down menus instead of these text boxes.
My question is, what's the "best" way to add a row of a certain type? Obviously columns are done easily, but is there a common method for a row type other than looping through and adding individual cells of that type to the datagridview?
The type of each cell can only be pre-determined by the column, not the row. As a result, you're going to have to add each cell individually. You can actually put a cell of any type anywhere you want. You simply create a cell of the desired type and assign it to the Item property of the grid, e.g.
myDataGridView(columnIndex, rowIndex) = newCell
You will simply have to use a For loop to do that for each valid column index with a single row index. Note that you'll have to create a new cell for each column, not reuse the same one.
I am trying to set the alignment of a specific cell in a row/column to be right aligned. However I do not want to set the whole row, or whole column to right aligned. Is it possible to set the cell only? From what I've seen online I'm starting to think it isn't possible.
You would need to hook up to the RowDataBound event. This fires as each row is databound. Check that the row is a data row (as opposed to a header or footer). Then check the value in the column you are interested in. If the value meets your criteria for right justification then apply that to the column in question.
Note if you are using AlternateItemTemplate then check both Item rows and AlternateItem rows.
I've used this method to say change the backround colour of values that fall outside a range.